{"id":6025,"date":"2017-05-03T12:00:27","date_gmt":"2017-05-03T16:00:27","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/azuregov\/?p=6025"},"modified":"2019-06-13T13:10:30","modified_gmt":"2019-06-13T20:10:30","slug":"setup-continuous-deployment-to-microsoft-azure-government-using-visual-studio-team-services","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azuregov\/setup-continuous-deployment-to-microsoft-azure-government-using-visual-studio-team-services\/","title":{"rendered":"Setup continuous deployment to Microsoft Azure Government using Visual Studio Team Services"},"content":{"rendered":"<p>Continuous integration (CI) and continuous deployment (CD) help teams reliably deliver quality apps to end customers at a faster pace of update. From code through build, test, and deployment you can define efficient and fully managed pipelines that automate and control the entire process.<\/p>\n<p><a href=\"http:\/\/aka.ms\/rmhelp\">Release Management in Visual Studio Team Services<\/a> is a powerful service that enables CD for various applications. Onetime configuration and repeated execution of the release pipelines means the automated delivery process is started whenever a new build is available.<\/p>\n<div style=\"box-sizing: border-box; font-family: 'Segoe UI', 'Helvetica Neue', 'Apple Color Emoji', 'Segoe UI Emoji', Helvetica, Arial, sans-serif; font-size: 16.93px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;\">Microsoft Azure Government has unique Azure endpoints to manage\u00a0the services offered there. Authentication using management certificate, user credentials or service principal for requests to the service management APIs are supported.<\/div>\n<p>Visual Studio Team Services enables requests to Azure Government environments with a CD process using <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/concepts\/library\/service-endpoints\">service endpoints<\/a> (Azure classic service endpoint for requests using management certificate or credentials, Azure resource manager service endpoint for requests using service principal authentication).<\/p>\n<p><strong>Visual Studio Team Services is currently not available in Microsoft Azure Government.<\/strong><\/p>\n<p>In this article, we&#8217;ll look at how you can configure continuous deployment for an Azure web site in Azure Government with a Team Services account. We&#8217;ll authenticate using service principal authentication.<\/p>\n<p>Note that this process would require orchestrating builds &amp; deployments, and storing the build artifacts outside the isolated environment. In case you require stricter data restrictions for your application, you can configure a <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/concepts\/agents\/agents#install\">private agent<\/a> on a VM in Azure Government. Refer to <a href=\"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2017\/04\/10\/deploying-to-on-premises-environments-with-visual-studio-team-services-or-team-foundation-server\/\">this<\/a> for more details.<\/p>\n<h4><span style=\"text-decoration: underline;\"><strong>Get set up<\/strong><\/span><\/h4>\n<p><strong>Begin with a CI build<\/strong><\/p>\n<p>Before you begin, you&#8217;ll need a CI build that publishes your Web Deploy package. To set up CI for your specific type of app, see:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/apps\/aspnet\/ci\/build-aspnet-4\">Build your ASP.NET 4 app<\/a><\/li>\n<li><a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/apps\/aspnet\/ci\/build-aspnet-core\">Build your ASP.NET Core app<\/a><\/li>\n<li><a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/apps\/node\/nodejs-to-azure\">Build your Node app with Gulp<\/a><\/li>\n<\/ul>\n<p><strong>Create the Azure app service<\/strong><\/p>\n<p>An <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/app-service-value-prop-what-is\/\">Azure App Service<\/a> is where we&#8217;ll deploy the <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/app-service-web-overview\/\">Web App<\/a>. Create a new web app in your subscription from the Azure Government portal.<\/p>\n<p><strong>Generate a service principal<\/strong><\/p>\n<ul>\n<li>Download &amp; run <a href=\"https:\/\/github.com\/Microsoft\/\">this Powershell script<\/a> in an Azure Powershell window to generate required data for Service Principal based Azure service connection. Running this script would prompt you for:\n<ul>\n<li>The name of your Azure Subscription<\/li>\n<li>A password that you would like to set for the Service Principal that is going to be created<\/li>\n<li>You should also provide the target environment&#8217;s name (Azure Government environment name) for your subscription in the environmentName parameter.<\/li>\n<\/ul>\n<\/li>\n<li>Once successful, the script would output the following details for the Azure Service Endpoint.\n<ul>\n<li>Connection Name<\/li>\n<li>Subscription Id<\/li>\n<li>Subscription Name<\/li>\n<li>Service Principal Client Id<\/li>\n<li>Service Principal key<\/li>\n<li>Tenant Id<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Configure a VSTS endpoint<\/strong><\/p>\n<ul>\n<li>From your Visual Studio Account, navigate to your Team Project and click on the gear icon.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-6035\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd1.png\" alt=\"cd1\" width=\"897\" height=\"102\" \/><\/a><\/p>\n<ul>\n<li>Click the Services tab and click on &#8216;New Service Endpoint&#8217; in the left pane.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd2.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-6045\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd2.png\" alt=\"cd2\" width=\"1123\" height=\"266\" \/><\/a><\/p>\n<ul>\n<li>From the drop-down, select &#8216;Azure Resource Manager&#8217; option.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd3.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-6055\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd3.png\" alt=\"cd3\" width=\"585\" height=\"286\" \/><\/a><\/p>\n<ul>\n<li>In the dialog, click the link at end of the text &#8220;If your subscription is not listed or to specify an existing service principal, click here&#8221;, which will switch to manual entry mode.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd4.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-6075\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd4.png\" alt=\"cd4\" width=\"701\" height=\"703\" \/><\/a><\/p>\n<ul>\n<li>Give the endpoint a friendly name, choose the target environment name and enter the details obtained from execution of the script while creating a service principal.<\/li>\n<\/ul>\n<h4><span style=\"text-decoration: underline;\">Define and test your CD release process<\/span><\/h4>\n<p>Continuous deployment (CD) means starting an automated release process whenever a new successful build is available. Your CD release process picks up the artifacts published by your CI build and then deploys them to your Azure web site.<\/p>\n<ol>\n<li>Do one of the following:\n<ul>\n<li>If you&#8217;ve just completed a CI build (see above), choose the link to the completed build (for example, <em>Build 1634<\/em>). In the build&#8217;s <strong>Summary<\/strong> tab under <strong>Deployments<\/strong>, choose <strong>Create release<\/strong> followed by <strong>Yes<\/strong>. This starts a new release definition that&#8217;s automatically linked to the build definition.<\/li>\n<li>Open the <strong>Releases<\/strong> tab of the <strong>Build &amp; Release<\/strong> hub, open the <strong>+<\/strong> drop-down in the list of release definitions, and choose <strong>Create release definition<\/strong><\/li>\n<\/ul>\n<\/li>\n<li>Select the <strong>Azure App Service Deployment<\/strong> template and choose <strong>Next<\/strong>.<\/li>\n<li>In <strong>Source&#8230;<\/strong> make sure your CI build definition for the Web deploy package is selected as the artifact source.<\/li>\n<li>Select the <strong>Continuous deployment<\/strong> check box, and then choose <strong>Create<\/strong>.<\/li>\n<li>Select the <strong>Deploy Azure App Service<\/strong> task and configure it as follows:<\/li>\n<\/ol>\n<table>\n<thead>\n<tr>\n<td><strong>Task step<\/strong><\/td>\n<td><strong>Parameters<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd5.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-6065\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/43\/2019\/03\/cd5.png\" alt=\"cd5\" width=\"32\" height=\"33\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/steps\/deploy\/azure-app-service-deploy\">Deploy: Azure App Service Deploy<\/a><\/p>\n<p>Deploy the app to Azure App Services<\/td>\n<td>\n<ul>\n<li><strong>Azure Subscription:<\/strong> Select the endpoint configured earlier<\/li>\n<li><strong>App Service Name<\/strong>: the name of the web app (the part of the URL <em>without<\/em> <strong>.azurewebsites.net<\/strong>).<\/li>\n<li><strong>Deploy to Slot<\/strong>: make sure this is cleared (the default)<\/li>\n<li><strong>Virtual Application:<\/strong> leave blank<\/li>\n<li><strong>Web Deploy Package:<\/strong> $(System.DefaultWorkingDirectory)\\**\\*.zip (the default)<\/li>\n<li><strong>Advanced: Take App Offline:<\/strong> If you run into locked .DLL problems when you test the release, as explained below, try selecting this check box.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>6. Edit the name of the release definition, choose <strong>Save<\/strong>, and choose <strong>OK<\/strong>. Note that the default environment is named Environment1, which you can edit by clicking directly on the name.<\/p>\n<p>You&#8217;re now ready to create a release, which means to start the process of running the release definition with the artifacts produced by a specific build.<\/p>\n<p>We welcome your comments and suggestions to help us continually improve your Azure Government experience. To stay up to date on all things Azure Government, be sure to subscribe to our <a href=\"https:\/\/blogs.msdn.microsoft.com\/azuregov\/feed\/\">RSS feed<\/a> and to receive emails, click &#8220;Subscribe by Email!&#8221;\u009d on the <a href=\"https:\/\/blogs.msdn.microsoft.com\/azuregov\/\">Azure Government Blog<\/a>. To experience the power of Azure Government for your organization, sign up for an <a href=\"https:\/\/azuregov.microsoft.com\/trial\/azuregovtrial\">Azure Government Trial<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuous integration (CI) and continuous deployment (CD) help teams reliably deliver quality apps to end customers at a faster pace of update. From code through build, test, and deployment you can define efficient and fully managed pipelines that automate and control the entire process. Release Management in Visual Studio Team Services is a powerful service [&hellip;]<\/p>\n","protected":false},"author":1767,"featured_media":5845,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,8,25,35],"tags":[51,75,91,247,485,584],"class_list":["post-6025","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcements","category-developer-services","category-portalpreview","category-web-mobile","tag-announcement","tag-azure","tag-azure-gov","tag-developers","tag-release-management","tag-visual-studio-team-services"],"acf":[],"blog_post_summary":"<p>Continuous integration (CI) and continuous deployment (CD) help teams reliably deliver quality apps to end customers at a faster pace of update. From code through build, test, and deployment you can define efficient and fully managed pipelines that automate and control the entire process. Release Management in Visual Studio Team Services is a powerful service [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/posts\/6025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/users\/1767"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/comments?post=6025"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/posts\/6025\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/media?parent=6025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/categories?post=6025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azuregov\/wp-json\/wp\/v2\/tags?post=6025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}