{"id":10676,"date":"2017-11-01T15:35:42","date_gmt":"2017-11-01T22:35:42","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/?p=10676"},"modified":"2017-11-01T15:35:42","modified_gmt":"2017-11-01T22:35:42","slug":"publishing-a-web-app-to-an-azure-vm-from-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/publishing-a-web-app-to-an-azure-vm-from-visual-studio\/","title":{"rendered":"Publishing a Web App to an Azure VM from Visual Studio"},"content":{"rendered":"<p>We know virtual machines (VMs) are one of the most popular places to run apps in Azure, but publishing to a VM from Visual Studio has been a tricky experience for some. So, we\u2019re pleased to announce that in Visual Studio 15.5 we\u2019ve added some improvements to the experience. In this post, we\u2019ll discussed the requirements for a VM that\u2019s ready to run an ASP.NET web application, and then walk through how to publish to it from Visual Studio.<\/p>\n<p>If you have a minute to <a target=\"_blank\" href=\"https:\/\/www.surveymonkey.com\/r\/AzureVMSurvey?trackID=webdev-blog\" rel=\"noopener\">answer two questions about your interest in VMs<\/a>, we\u2019d appreciate it!<\/p>\n<h4>Create a new VM on Azure<\/h4>\n<p>Click the button below to deploy <a target=\"_blank\" href=\"https:\/\/github.com\/aspnet\/Tooling\/blob\/AspNetVMs\/VMSetup\/ASPNet-ARMTemplate.json\" rel=\"noopener\">this custom Azure Resource Manager (ARM) Template<\/a>, which will create a new Azure VM with all required components installed and configured. <a target=\"_blank\" href=\"https:\/\/portal.azure.com\/#create\/Microsoft.Template\/uri\/https%3A%2F%2Fraw.githubusercontent.com%2Faspnet%2FTooling%2FAspNetVMs%2FVMSetup%2FASPNet-ARMTemplate.json\" rel=\"noopener\"><img decoding=\"async\" alt=\"Create ASP.NET VM in Azure\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/CreateAzureVM.png\" \/><\/a> Note: It&#8217;s also possible to <a target=\"_blank\" href=\"https:\/\/github.com\/aspnet\/Tooling\/blob\/AspNetVMs\/docs\/create-asp-net-vm-with-webdeploy.md\" rel=\"noopener\">update an existing VM<\/a>.<\/p>\n<p>To use the Visual Studio VM publish wizard, you must <a target=\"_blank\" href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/windows\/portal-create-fqdn\" rel=\"noopener\">assign a DNS name to the VM<\/a>. <a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ConfigureDNSName1.png\"><img decoding=\"async\" width=\"700\" class=\"alignnone size-full wp-image-10767\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ConfigureDNSName1-1.png\" \/><\/a><\/p>\n<h4>Walk-through: Publishing a web app to an Azure Virtual Machine from Visual Studio 2017<\/h4>\n<ol>\n<li>Open your web application in Visual Studio 2017<\/li>\n<li>Right-click the project and choose &#8220;Publish\u2026&#8221;<\/li>\n<li>Press the arrow on the right side of the page to scroll through the publishing options until you see &#8220;Microsoft Azure Virtual Machine&#8221;. <a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Publish-ScrollArrow.png\"><img decoding=\"async\" width=\"700\" class=\"alignnone size-full wp-image-10697\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Publish-ScrollArrow-1.png\" \/><\/a><\/li>\n<li>Select the \u201cMicrosoft Azure Virtual Machine\u201d icon, then click &#8220;Browse&#8230;&#8221; to open the Azure Virtual Machine selector. <a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Publish-AzureVM.png\"><img decoding=\"async\" width=\"700\" class=\"alignnone size-full wp-image-10696\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Publish-AzureVM-1.png\" \/><\/a>The Azure VM selector dialog will open.<\/li>\n<li>Choose the appropriate account (with Azure subscription connected to your virtual machine). \n<ul>\n<li>If you\u2019re signed in to Visual Studio, the account list will be pre-populated with all your authenticated accounts.<\/li>\n<li>If you are not signed in, or if the account you need is not listed, choose \u201cAdd an account\u2026\u201d and follow the prompts to log in.\n<a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ChooseVM-SelectAccount-1.png\"><img decoding=\"async\" width=\"500\" class=\"alignnone size-full wp-image-10705\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ChooseVM-SelectAccount-1-1.png\" \/><\/a>Wait for the list of Existing Virtual Machines to populate. (Note: This can take some time).<\/li>\n<\/ul>\n<\/li>\n<li>From the Existing Virtual Machines list, select the VM that you intend to publish your web application to, then press &#8220;OK&#8221;.<a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ChooseVM-SelectVM-1.png\"><img decoding=\"async\" width=\"500\" class=\"alignnone size-full wp-image-10715\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ChooseVM-SelectVM-1-1.png\" \/><\/a>Focus returns to the Publish page with the Azure Virtual Machine populated and the &#8220;Publish&#8221; button enabled.<\/li>\n<li>Press the &#8220;Publish&#8221; button to create the publish profile and begin publishing to your Azure VM. Note: You can <a target=\"_blank\" href=\"https:\/\/blogs.msdn.microsoft.com\/webdev\/2017\/10\/31\/recent-updates-for-publishing\/\" rel=\"noopener\">delay publishing<\/a> so you can configure additional settings prior to your first publish as <a href=\"#ModifySettings\">covered later in the post<\/a>.\n<a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Publish-PublishButton.png\"><img decoding=\"async\" width=\"700\" class=\"alignnone size-full wp-image-10745\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Publish-PublishButton-1.png\" \/><\/a> <\/li>\n<li>When prompted for User name and Password, enter the credentials of a user who is authorized for publishing web applications on the VM, then press \u201cOK\u201d. <em><strong>Note:<\/strong> For new VMs, this is usually the administrator account. To enable non-administrator user accounts with permission to publish via WebDeploy, follow the steps in <a target=\"_blank\" href=\"https:\/\/docs.microsoft.com\/en-us\/iis\/manage\/remote-administration\/configuring-remote-administration-and-feature-delegation-in-iis-7\" rel=\"noopener\">this document<\/a>.<\/em>\n<a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ProvideUsernamePassword.png\"><img decoding=\"async\" width=\"322\" height=\"261\" class=\"alignnone size-full wp-image-10735\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ProvideUsernamePassword-1.png\" \/><\/a> <\/li>\n<li>If prompted, accept the security certificate.\n<a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/SecurityCertError.png\"><img decoding=\"async\" width=\"400\" class=\"alignnone size-full wp-image-10756\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/SecurityCertError-1.png\" \/><\/a> <\/li>\n<li>Publishing proceeds. You can watch the progress in the Output window. <a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ProgressInOutputWindow.png\"><img decoding=\"async\" width=\"587\" height=\"191\" class=\"alignnone size-full wp-image-10726\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/ProgressInOutputWindow-1.png\" \/><\/a>When publishing completes, a web browser will launch and open at the destination URL of the web site hosted on the Azure VM. Note: If you don&#8217;t want the web browser launching after each publish, remove the &#8220;Destination URL&#8221; from the Publish Profile settings.<\/li>\n<\/ol>\n<p><strong>Success!<\/strong><\/p>\n<p>At this point, you have finished publishing your web application to the VM. The Publish page refreshes with the new profile selected and the details shown in the Summary section.<\/p>\n<p>You can return to this screen any time to publish again, rename or delete the profile, launch the web site in a browser, or modify the publish settings. Read on to learn about some interesting settings.<\/p>\n<h4>Modify Publish Settings [Optional]<\/h4>\n<p>After the Publish Profile has been created, you can edit the settings to tweak your publishing experience. To modify the settings of the publish profile, click the &#8220;Settings\u2026&#8221; link on the Publish page.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Profile-Settings.png\"><img decoding=\"async\" width=\"700\" class=\"alignnone size-full wp-image-10716\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/Profile-Settings-1.png\" \/><\/a><\/p>\n<p>This will open the Publish Profile Settings dialog.<\/p>\n<h5>Save user credentials to the profile<\/h5>\n<p>To avoid having to provide user name and password each time you publish, you can store the user credentials in the publish profile.<\/p>\n<li style=\"list-style-type: none\">\n<ol>\n<li>\n      In the &#8220;User name&#8221; and &#8220;Password&#8221; fields, enter the credentials of an authorized user on the target VM.\n    <\/li>\n<li>\n      Press &#8220;Validate Connection&#8221; to confirm that the details are correct.\n    <\/li>\n<li>\n      Choose &#8220;Save password&#8221; if you don&#8217;t want to be prompted to enter the password each time you publish.\n    <\/li>\n<\/ol>\n<\/li>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/PublishSettings-UserPwd.png\"><img decoding=\"async\" width=\"600\" class=\"alignnone size-full wp-image-10755\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/PublishSettings-UserPwd-1.png\" \/><\/a><\/p>\n<ol>\n<li>Click &#8220;Next&#8221; to progress to the &#8220;Settings&#8221; tab, or click \u201cSave\u201d to accept the changes and close the dialog.<\/li>\n<\/ol>\n<h5>Ensure a clean publish each time<\/h5>\n<p>To ensure that your web application is uploaded to a clean web site each time you publish, you can configure the publish profile to delete all files on the target web server before publishing.<\/p>\n<ol>\n<li>Go into the \u201cSettings\u201d page of the Publish dialog.<\/li>\n<li>Expand the File Publish Options.<\/li>\n<li>Choose &#8220;Remove additional files at destination&#8221;. <a href=\"http:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/PublishSettings-RemoveFiles.png\"><img decoding=\"async\" width=\"600\" class=\"alignnone size-full wp-image-10747\" alt=\"\" src=\"https:\/\/devblogs.microsoft.com\/aspnet\/wp-content\/uploads\/sites\/16\/2017\/11\/PublishSettings-RemoveFiles-1.png\" \/><\/a>Warning! Deleting files on the target VM may have undesired effects, including removing files that were uploaded by other team members, or files generated by the application. Please be sure you know the state of the machine before publishing with this option enabled.<\/li>\n<\/ol>\n<h4>Conclusion<\/h4>\n<p>We\u2019d love for you to install the 15.5 update\u00a0and let us know what you think of the new experience. Also, if haven&#8217;t already, please\u00a0 take one minute <a target=\"_blank\" href=\"https:\/\/www.surveymonkey.com\/r\/AzureVMSurvey?trackID=webdev-blog\" rel=\"noopener\">to answer two questions about your interest in VMs in the cloud<\/a>. As always please let us know what you think in the comments section below, by using the send feedback tool in Visual Studio, or via <a href=\"https:\/\/twitter.com\/justcla78\">Twitter<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We know virtual machines (VMs) are one of the most popular places to run apps in Azure, but publishing to a VM from Visual Studio has been a tricky experience for some. So, we\u2019re pleased to announce that in Visual Studio 15.5 we\u2019ve added some improvements to the experience. In this post, we\u2019ll discussed the [&hellip;]<\/p>\n","protected":false},"author":467,"featured_media":20556,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197,327],"tags":[],"class_list":["post-10676","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","category-azure"],"acf":[],"blog_post_summary":"<p>We know virtual machines (VMs) are one of the most popular places to run apps in Azure, but publishing to a VM from Visual Studio has been a tricky experience for some. So, we\u2019re pleased to announce that in Visual Studio 15.5 we\u2019ve added some improvements to the experience. In this post, we\u2019ll discussed the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/10676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/467"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=10676"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/10676\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=10676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=10676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=10676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}