{"id":29386,"date":"2017-04-10T11:22:41","date_gmt":"2017-04-10T18:22:41","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/?p=29386"},"modified":"2019-02-14T15:55:38","modified_gmt":"2019-02-14T23:55:38","slug":"deploying-to-on-premises-environments-with-visual-studio-team-services-or-team-foundation-server","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/deploying-to-on-premises-environments-with-visual-studio-team-services-or-team-foundation-server\/","title":{"rendered":"Deploying to On-Premises Environments with Visual Studio Team Services or Team Foundation Server"},"content":{"rendered":"<blockquote><p><em>I hear this particular question frequently as a reason teams are concerned about adopting Visual Studio Team Services when their applications still run on-premises. \u00a0The good news is that it is typically a quick walkthrough on how build &amp; deployment pipelines work. \u00a0I want to give a big thanks to <a href=\"http:\/\/blog.nwcadence.com\/author\/sachi-williamson\/\">Sachi Williamson<\/a> from <a href=\"http:\/\/www.nwcadence.com\/\">Northwest Cadence<\/a> for the guest blog post today!<\/em> &#8212; <strong>Ed Blankenship<\/strong><\/p><\/blockquote>\n<p>Your company\u2019s apps may not be hosted in the cloud yet for various reasons, such as their configuration, dependencies, or network requirements. That\u2019s okay!\u00a0\u00a0 What many people don\u2019t know is that you can still take advantage of great tools like <a href=\"https:\/\/www.visualstudio.com\/team-services\/\">Visual Studio Team Services<\/a> or <a href=\"https:\/\/www.visualstudio.com\/tfs\/\">Team Foundation Server<\/a> to manage your deployments.\u00a0 You\u2019re probably asking yourself, \u201chow can a cloud SaaS service like Team Services be able to deploy to our on-premises environments?\u201d\u00a0 That\u2019s what we will explore today.<\/p>\n<p>For the core service, your team has a choice to either use Visual Studio Team Services as a completely hosted SaaS service by Microsoft or you can run it on-premises by setting up Team Foundation Server (TFS). \u00a0When you build and deploy your apps through Team Services or TFS, you use agents to run the build and deployment tasks. \u00a0Team Services allows you to take advantage of <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/concepts\/agents\/hosted\">hosted agents<\/a> for running your build and deployment pipelines. \u00a0The hosted agents are perfect for many scenarios including your automated build process. \u00a0However, when you want to deploy on-premises, you will want to run the deployment steps from agents that have access to your on-premises environment. \u00a0This alternative scenario is enabled through leveraging <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/concepts\/agents\/agents\">private agents<\/a>.<\/p>\n<h2><strong>How does an agent communicate with Team Services or TFS?<\/strong><\/h2>\n<p><strong><\/strong>The agent communicates with Team Services or TFS to determine which pipeline tasks it needs to run in addition to reporting log entries and job status. This communication is always initiated by the agent. All the messages from the agent to Team Services or TFS happen over HTTP or HTTPS, depending on how you configure the agent. This polling model allows the agent to be configured in different topologies as shown below. \u00a0In the Team Services example, you&#8217;ll notice we included an additional scenario where you are running a &#8220;private agent&#8221; in a cloud-hosted virtual machine as well.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/04\/DeployOnPrem1.png\" alt=\"deployonprem1\" width=\"674\" height=\"584\" class=\"aligncenter size-full wp-image-29425\" \/><\/p>\n<h2><strong>How does an agent communicate with target servers for deployment?<\/strong><\/h2>\n<p><strong><\/strong>When you use the agent to deploy artifacts to a target set of servers, the agent\u00a0must have &#8220;line of sight&#8221; connectivity to those servers. The hosted agents pool, by default, has connectivity to from the Azure cloud to anything else running in the Azure cloud or exposed to the public Internet. \u00a0For example, you may have <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/apps\/cd\/deploy-webdeploy-webapps\">an Azure Website that a hosted agent is able to deploy to through endpoints exposed through the Azure App Service platform<\/a>.<\/p>\n<p>If your on-premises environments do not have connectivity to the hosted pool (which is typically the case because of\u00a0firewalls), you\u00a0will want to setup and\u00a0configure a private agent on servers hosted in your on-premises network. The private agents need to have\u00a0connectivity to the target on-premises environments where you want to deploy, and also have access to the Internet to connect to Team Services, as shown in the following diagram. \u00a0If you are using Team Foundation Server, you will connect your private agent to your Team Foundation Server.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/04\/DeployOnPrem2.png\" alt=\"deployonprem2\" width=\"590\" height=\"373\" class=\"aligncenter size-full wp-image-29435\" \/><\/p>\n<p>To read more on communication and deployment to target servers, check out this <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/concepts\/agents\/agents\">documentation<\/a>.<\/p>\n<h2><strong>How do I deploy from Team Services\u00a0or TFS to on-premises environments?<\/strong><\/h2>\n<p>Build and deployment agents can run on many platforms. \u00a0There are a few walkthroughs available for setting up your agent on various operating systems:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/actions\/agents\/v2-windows\">Deploy an agent on Windows<\/a><\/li>\n<li><span> <\/span><a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/actions\/agents\/v2-osx\">Deploy an agent on OSX<\/a><\/li>\n<li><span> <\/span><a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/build\/actions\/agents\/v2-linux\">Deploy an agent on Linux<\/a><\/li>\n<\/ul>\n<p><u><\/u>One step that you will need to take is to setup the ability for the agent to authenticate with your Team Services account or your Team Foundation Server. \u00a0One approach for authenticating is creating a <a href=\"https:\/\/www.visualstudio.com\/en-us\/docs\/setup-admin\/team-services\/use-personal-access-tokens-to-authenticate\">Personal Access Token (PAT)<\/a>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/04\/DeployOnPrem3.png\" alt=\"deployonprem3\" width=\"893\" height=\"713\" class=\"aligncenter size-full wp-image-29445\" \/><\/p>\n<p>The next step for setting up your private agent is to\u00a0download and install the agent software on\u00a0the server you want to run the deployment tasks. \u00a0Team Services and TFS allow you to group many agents into &#8220;pools&#8221; which you will use later when configuring the pipeline to decide which pool of agents to use. \u00a0For this example, you can add your private agent to the &#8220;Default&#8221; pool or you can create a new &#8220;On-premises&#8221; pool.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/04\/DeployOnPrem4.png\" alt=\"deployonprem4\" width=\"720\" height=\"255\" class=\"aligncenter size-full wp-image-29455\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/04\/DeployOnPrem5.png\" alt=\"deployonprem5\" width=\"727\" height=\"249\" class=\"aligncenter size-full wp-image-29396\" \/><\/p>\n<p>Now you can start editing your release pipeline. \u00a0In default pipelines, you will notice the &#8220;Run on agent&#8221; scope for your each of your environments. \u00a0If you select it, you will see a &#8220;deployment queue&#8221; option to choose which pool of agents you want to run these deployment tasks on. \u00a0Since we want to run these tasks against on-premises environments, we should select the &#8220;On-premises&#8221; agent pool that we created in the previous step.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/04\/DeployOnPrem6-1024x295.png\" alt=\"deployonprem6\" width=\"879\" height=\"253\" class=\"aligncenter size-large wp-image-29405\" \/><\/p>\n<p>You can now queue a new release. \u00a0Once the release starts you&#8217;ll notice that it will choose a private agent from the on-premises pool and run any deployment steps on your on-premises network.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2017\/04\/DeployOnPrem7.png\" alt=\"deployonprem7\" width=\"582\" height=\"246\" class=\"aligncenter size-full wp-image-29415\" \/><\/p>\n<p>That\u2019s release all there is to it! \u00a0Whether your environments are on-premises or hosted in any cloud, Visual Studio Team Services and Team Foundation Server make it simple to deploy to any of your environments using private agents.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I hear this particular question frequently as a reason teams are concerned about adopting Visual Studio Team Services when their applications still run on-premises. \u00a0The good news is that it is typically a quick walkthrough on how build &amp; deployment pipelines work. \u00a0I want to give a big thanks to Sachi Williamson from Northwest Cadence [&hellip;]<\/p>\n","protected":false},"author":105,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-29386","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"acf":[],"blog_post_summary":"<p>I hear this particular question frequently as a reason teams are concerned about adopting Visual Studio Team Services when their applications still run on-premises. \u00a0The good news is that it is typically a quick walkthrough on how build &amp; deployment pipelines work. \u00a0I want to give a big thanks to Sachi Williamson from Northwest Cadence [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/29386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=29386"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/29386\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=29386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=29386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=29386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}