Configure Visual Studio Team Services in Visual Studio, deploy to Azure App Service


I am on a path to learning and working with a Continuous Deployment / Delivery (CD), I just need a project or to build some examples that are worthy of such a great concept.  What I see happening in that area is pretty awesome, for example, with CD you can check in your code, build, test and deploy automatically.  Awesome yes, but from an Azure App Service perspective, the deployment happens to a deployment slot and not directly to production, which is a very risky endeavor.  CD is a topic in the near future.  In this article I discuss configuring my source code with Visual Studio Team Services (VSTS) from within Visual Studio 2017 and then the configuration of the Deployment Options within the Azure Portal, here, noting that when you do this, when you make a change, commit it and sync it with VSTS, that the change is pushed right into the production slot.

Here are a few other articles which I have written about deployments and source code management which might help.

The steps I performed to store my source code in VSTS and then link it to an Azure App Service were:

  • Add the code to VSTS
  • Configure the Deployment options in Azure
  • Make a change, commit and deploy

I assume that a VSTS and Azure account already exist and you can create and configure an Azure App Service.

Add the code to VSTS

In Visual Studio 2017 I created a test Web Project, and as shown in Figure 1, right-clicked the Solution and selected ‘Add Solution to Source Control’.

image

Figure 1, how to add solution to source control in visual studio 2017 visual studio team services

Once added, click on the Sync button as shown in Figure 2, on the Team Explorer tab in Visual Studio 2017.

image

Figure 2, how to sync source in visual studio 2017 visual studio team services

The first time I did this, as I had not configured VSTS I was prompted to perform the authentication and configurations as seen in Figure 3.

image

Figure 3, how to add solution to source control in visual studio 2017 visual studio team services

After entering in all the credentials and my VSTS domain where I wanted to store the source code, I selected the Publish repository button as seen in Figure 4.

image

Figure 4, how to publish solution to source control in visual studio 2017 visual studio team services

Once successful, I could see the source code within VSTS using my browser, as seen in Figure 5.

image

Figure 5, view published solution to source control from visual studio 2017 in visual studio team services

Now the source code is under version control and you need to make the link between VSTS and your Azure App Service.

Configure the Deployment options in Azure

Select the Azure App Service you want to deploy the source code to.  Then click on the Deployment options, configure required settings and select Visual Studio Team Services as seen in Figure 6.

image

Figure 6, configure visual studio team services in azure portal for an azure app service

Choose your project and the branch then click the OK button.

image

Figure 7, configure visual studio team services in azure portal for an azure app service

You will then see the synchronization of the source code repository stored on Visual Studio Team Services being synced to the Azure App Service,  This happens automatically, as seen in Figure 8.

image

Figure 7, configure visual studio team services in azure portal for an azure app service and sync it

Once complete you see the success message, Figure 8 and you can access and use you site.

image

Figure 8, configure visual studio team services in azure portal for an azure app service and sync it

Make a change, commit and deploy

When you make a change to source code that is stored on VSTS, you are only making a local change, it is not reflected in the source code currently stored on VSTS until you commit and sync the change.  As you see in Figure 9, a change was sync to the production slot of the Azure App Service.  This happened automatically after I committed and synced that change from within Visual Studio 2017.

image

Figure 9, commit and sync code changes in visual studio 2017 then they are deployed to my azure app service

You can also see the logs of deployments from the VSTS portal itself, Figure 10.

image

Figure 10, commit and sync code changes in visual studio 2017 then they are deployed to my azure app service, view the logs

Cool stuff, but don’t deploy straight to production!

Comments (0)

Skip to main content