ASP.NET Core – Web Deploy to Azure VM

The ASP.NET Core documentation includes instructions for publishing to IIS using Web Deploy from Visual Studio, but there were a few steps that weren’t covered.  For my reference in the future, I am documenting the process of creating a Windows Server VM in Azure, configuring it for Web Deploy, and using Web Deploy in Visual Studio 2015 to publish an ASP.NET Core application.

Azure VM Configuration

After creating the Windows Server VM in Azure, use the Add Roles and Features Wizard to install the Web Server web role, as described in the documentation.

Allowing Inbound HTTP Traffic

To allow browsing to the web site from outside, you have to set up an inbound security rule.  On the Azure Dashboard, select Browse > at the bottom of the left panel.  Select Network security groups and select the security group for the VM.  On the settings panel for the security group, select Inbound security rules and add a new rule.  Choose TCP as the protocol and 80 as the Destination port range.  After saving this rule, browse to the VM from another machine and you should see the default IIS page.

create-azure-vm-01

Install Web PI and Web Deploy

Install Web Platform Installer 5 on the VM.  Run Web PI, search for “web deploy” and install “Web Deploy 3.6 for Hosting Servers”.

Go back to the Azure Dashboard and create an inbound security rule for Web Deploy, which uses TCP port 8172:

net46-publish-05

Install Hosting for ASP.NET Core

Install support for hosting .NET Core on Windows Servers:  http://go.microsoft.com/fwlink/?LinkId=798480

Publishing with Web Deploy and VS 2015

The documentation suggests importing a publish profile to publish an ASP.NET Core application using Web Deploy.  To create a publish profile, go to IIS Manager, right-click the web site, choose Deploy then Configure Web Deploy Publishing....  Click Setup and copy the publish settings file to your development machine.

core-webdeploy-02

Creating a Publish Profile

In the Visual Studio Publish dialog, import the profile and update the information as needed.  You can verify the settings with the Validate Connection button.

core-webdeploy-04a

At this point, you can Publish the site if your VM has a valid SSL certificate.  If it is using the default self-signed certificate, which will be the case if you just created the VM, you will need to manually edit the publish file first.

Close the Publish dialog to save the settings to a file.  Edit the settings file, which you can find in the project’s Properties\PublishProfiles folder.  Add the <AllowUntrustedCertificate>True</AllowUntrustedCertificate> element as shown below:

core-webdeploy-05

Save the publish file and you can now publish your ASP.NET Core application to the VM.

Leave a Reply