How to prepare a azure service principal

you can create an azure service principal for example using Azure CLI or using App registrations in AzureAD.
We only cover creating it with Azure CLI.

Create service principal using Azure CLI

Login into Azure

az login

Create service principal. Feel free to adjust the name. You must enter your-own-azure-subscription-id. A subscription Id look something like this: b35222fa-544e-4efe-5371-39245a3ce429
At the same time we assign a role to it, so that the service principal has access to our subscription.

az ad sp create-for-rbac \
  --name="mysp" \
  --role="Contributor" \
  --scope="/subscriptions/<subscription-id>" \

The output will be some thing like this:

  "appId": "fb745d15-5931-16c6-a450-13d2fa1bd3be",
  "displayName": "mysp",
  "password": "4J26HCd1113Jw_IsNHjkeiJnv,m8549FQM*38Ydfgu",
  "tenant": "1d3b4933-1101-8383-f134-667d1b9f1ba1"