Site icon TechGit

Connect Visual Studio Team Services to Azure Using a Service Principal Name

 

In today’s Ask the Admin, I will show you how to connect Visual Studio Team Services (VSTS) to Azure using a Service Principal Name (SPN) so that you can deploy code directly to Azure from VSTS.

VSTS allows sysadmins and developers to build apps on code in a VSTS project directly in Azure. VSTS uses an Azure Resource Manager (ARM) service endpoint to connect to Azure. If you use the same account to log into VSTS and Azure, give the connection a name to set up a new endpoint. Then, select the Azure subscription from the dropdown menu.

I recently came across a problem. If the Microsoft account used to log into VSTS is different from the one used for your Azure tenant, you will not be able add an ARM service endpoint to VSTS. You have to perform extra configuration. The solution to the problem, create an SPN in the Azure Active Directory (Azure AD) associated with the Azure tenant. This is where the app will be deployed.

Add an ARM Service Endpoint in Visual Studio Team Services

Let’s look at how to add an ARM service endpoint in VSTS without an SPN.

Add a new service endpoint in Visual Studio Team Services (Image Credit: Russell Smith)

Add a New Service Endpoint in Visual Studio Team Services (Image Credit: Russell Smith)

Add a new service endpoint in Visual Studio Team Services (Image Credit: Russell Smith)

Add a New Service Endpoint in Visual Studio Team Services (Image Credit: Russell Smith)

What if the Azure subscription you want to connect to is not associated with the account you use to log into VSTS? The dropdown menu will be empty. In this case, you will need to create an Azure AD SPN.

Create an Azure Active Directory Service Principal Name

Microsoft has a script (SPNCreation.ps1) on GitHub for creating Azure AD SPNs. To run it, you will need Microsoft Azure Powershell installed on your PC. I recommend using the Web Platform Installer 5.0 to install the necessary components.

Create a Service Principal Name in Azure Active Directory (Image Credit: Russell Smith)

Create a Service Principal Name in Azure Active Directory (Image Credit: Russell Smith)

The script will now run. When it is done, you will see information about the new SPN. You will need to enter in VSTS:

If you want to get a list of the configure SPNs for your Azure AD, type Get-AzureRmADServicePrincipal into the output pane at the bottom of the ISE. Press ENTER.

Add an ARM Service Endpoint in Visual Studio Team Services Using a Service Principal Name

Now that the SPN has been created in Azure, you need to add the information output by the script in VSTS. Follow the instructions for adding an ARM service endpoint. This will get you to the Add Azure Resource Manager Service Endpoint dialogue.

Add a new service endpoint in Visual Studio Team Services (Image Credit: Russell Smith)

Add a New Service Endpoint in Visual Studio Team Services (Image Credit: Russell Smith)

The new service endpoint will appear in the list on the left. You will now be able to build the project in VSTS and the Azure AD SPN will appear in the list of available Azure Subscriptions.

In this article, I showed you how to add an ARM service endpoint in VSTS and how to create an Azure AD SPN.

The post Connect Visual Studio Team Services to Azure Using a Service Principal Name appeared first on Petri.

FacebookTwitterTumblrRedditLinkedInHacker NewsDiggBufferGoogle ClassroomThreadsXINGShare
Exit mobile version