I was creating a new demo for an upcoming event and needed a clean VSTS account, so I started completely from scratch and created a brand new VSTS account. Next, I added my source code, created my build and started creating my release. The first thing I wanted to do was use the Azure App Service Deploy task to deploy my web app to an azure app service in one of my subscriptions. The task needed a connection to the Azure subscription of my app service.
Ah man!!! My Azure subscription isn’t linked to the current user of my VSTS account. Crap, it’s not in the drop down. I need to create an Azure service connection. Ok, easy enough. I’ve done this before… Hmmm… I can never remember how to do this simple task. Maybe I should write a blog about it so I can stop looking up how to do this every time I need to create an Azure service connection in VSTS
- Click on your gears > Services. This should take you to the Service Endpoints page
- click on the + New Service Endpoint and select Azure Resource Manager
- This brings up the Add Azure Resource Manager Service Endpoint. If I click on the Subscription drop down, you’ll notice that I can’t find the right Azure subscription (my Azure subscription is not linked in any way to my user id used to create my VSTS account). This means I’ll have to use the full version of the dialog box. Click the link “User the full version of the dialog”
- This brings up the full dialog. Enter a connection name. For environment, choose if your subscription is in Azure, Azure China, Azure US Gov, or Azure Germany
- Next comes Subscription ID, Subscription Name, Service Principal Client ID, Service Principal Key, Tenant ID. If we go and create the Service Principal Client ID and Service Principal Key first and then fill in the Tenant ID andclick Verify connection, the dialog will fill in the Subscription Id for us and the Subscription Name. So great. Let’s go and create the Service Principal Client ID and also create the key. Hmmm…. how do I do that? Quick search…. here you go https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal. Follow the instructions here. Start at Create an Azure active directory application and work your way all the way down to and including Assign Application to Role. This will give you your Service Principal ID, your Service Principal Key and your Tenant ID. Fill those in, click Verify connection and Ok, and voila! You have now created your azure service endpoint.
After creating your azure service endpoint, going back to your release, your service endpoint is now in your drop down. Select it and continue on with your release definition!