Continuous Deployment From Remote TFS to Local Web Server
Contents
Build
Please read Continuous Integration TFS Online - Create a Build for "How to build".
Create personal access tokens (PAT) to authenticate access
- Sign in to either your Visual Studio Team Services account (https://{youraccount}.visualstudio.com) or your Team Foundation Server web portal (https://{server}:8080/tfs/).
- From your home page, open your profile. Go to your security details.
- Create a personal access token.
- Name your token. Select a lifespan for your token.
- Select the scopes that this token will authorize for your specific tasks. For example, to create a token to enable a build and release agent to authenticate to Team Services or TFS, limit your token's scope to Agent Pools (read, manage).
- When you're done, make sure to copy the token. You'll use this token as your password.
Deployment group
Carry out the following steps in your Team Services account to create a Deployment Group consisting of the target IIS servers.
- Open the Deployment groups tab of the Build & Release hub and choose + New to create a new group
- Enter a name for the group in the Details tab and then choose Create.
- Set (tick) the Use a personal access token checkbox.
- Choose Copy script to clipboard.
- Sign into each of the IIS server where you will deploy your web app, and perform the following steps:
- .NET Framework 3.5 must be installed on servers in order to run MSDeploy
- Open an Administrator Powershell command prompt on each of the target IIS servers and paste the script you copied, then execute it to register the machine with this group.
- When prompted to configure tags for the agent, press Y and enter web.
- When prompted for the user account, press Return to accept the defaults.
- Wait for the script to finish with a message Service vstsagent.account.computername started successfully.
- In the Deployment groups page of the Build & Release hub, open the Machines tab and verify that the agent is running. If the tag named web is not visible, refresh the page.
Define and test your CD release process
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 IIS servers.
- Do one of the following:
- If you've just completed a CI build (see above) then, in the build's Summary tab under Deployments, choose Create release followed by Yes. This starts a new release definition that's automatically linked to the build definition.
- Open the Releases tab of the Build & Release hub, open the + drop-down in the list of release definitions, and choose Create release definition.
- Select the IIS Website and SQL Database Deployment template and choose Next.
- In the Artifacts section, make sure your CI build definition that publishes the Web deploy package is selected as the artifact source.
- Select the Continuous deployment check box, and then choose Create.
- Select the second SQL Deployment section containing the SQL DB Deploy task and delete it (you will not be deploying a database in this example).
- Configure the phases and tasks in the environment as follows:
- Run on deployment group phase for configuration of web servers.
- Deployment Group: Select the deployment group you created earlier.
- Machine tags: web
- IIS Web App Manage Deploy: IIS Web App Manage - Create or update the websites. (These depend on how you configure in your IIS)
- Website Name: Default Web Site. If you created a different website on the IIS servers, use that name instead.
- Port: 80
- IIS Application pool: DefaultAppPool
- IIS Web App Deploy Deploy: IIS Web App Deploy - Deploy the app to IIS.
- Website Name: Default Web Site. If you created a different website on the IIS servers, use that name instead.
- Run on deployment group phase for configuration of web servers.
- Edit the name of the release definition, choose Save, and choose OK. Note that the default environment is named "Environment1", which you can edit by selecting the name.
You'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. This will result in deploying the build to the IIS servers:
- Choose + Release and select Create Release.
- Select the build you just completed in the highlighted drop-down list and choose Create.
- Choose the release link in the popup message. For example: "Release Release-1 has been created".
- Open the Logs tab to watch the release console output.
- After the release is complete, navigate to your site running on the IIS servers, and verify its contents.
Read https://www.visualstudio.com/en-us/docs/build/apps/cd/deploy-webdeploy-iis-deploygroups for more
it will be listed under On-Premises pool
Release Pipeline
Now you can start editing your release pipeline. In default pipelines, you will notice the “Run on agent” scope for your each of your environments. If you select it, you will see a “deployment queue” option to choose which pool of agents you want to run these deployment tasks on. Since we want to run these tasks against on-premises environments, we should select the “On-premises” agent pool that we created in the previous step.
You can now queue a new release. Once the release starts you’ll notice that it will choose a private agent from the on-premises pool and run any deployment steps on your on-premises network.
Done


