Build with Jenkins in Azure
Create an Azure service principal
You need an Azure service principal to create an Azure Container Instances in Azure. You can think of Azure service principal as a ‘user identity’ (login and password or certificate) with a specific role, and tightly controlled permissions to access your resources in Azure.
-
If you don’t already have an Azure service principal, use Cloud Shell, an interactive, browser-accessible shell for managing Azure resources, to create one. Go to Azure Portal and launch Cloud Shell from the top navigation.
- Follow the instructions to select the environment and subscription to use.
- In Cloud Shell, run:
az ad sp create-for-rbac --name "uuuuuuuu" --password "pppppppp"
Where uuuuuuuu is the user name and pppppppp is the password for the service principal.
-
Azure responds with JSON that resembles the following examples:
{ "appId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "displayName": "uuuuuuuuuu", "name": "http://uuuuuuuu", "password": "pppppppp", "tenant": "tttttttt-tttt-tttt-tttt-tttttttttttt" }
You will use the values from this JSON response when you add the Azure Service Principal to Jenkins using the Azure Credential plugin. The aaaaaaaa, uuuuuuuu, pppppppp, and tttttttt are placeholder values.
Add Azure service principal to Jenkins
Next, you need to add the Azure service principal to Jenkins credential store using the Azure credential plugin.
- From the Jenkins dashboard, select Credentials
- Select System and then Add Credentials
- In the Add Credentials dialog, select Microsoft Azure Service Principal from the Kind drop-down.
-
If you don’t know your Azure subscription ID, you can query it from the Cloud Shell:
az account list
Enter your subscription ID. Use the
appId
value for Client ID,password
for Client Secret, andtenant
for Tenant ID.Provide
mySP
as the ID for this crediatial and enterAzure service principal
for description.
Verify the service principal authenticates with Azure by clicking Verify Service Principal
I ran into an issue I have an Azure service principal