官术网_书友最值得收藏!

  • Learning DevOps
  • Mikael Krief
  • 231字
  • 2021-06-24 12:32:05

Creating the Azure SP

This operation can be done either via the Azure portal (all steps are detailed on the official documentation here: https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal) or via a script by executing the following az cli command (which we can launch in Azure Cloud Shell).

The following is a template az cli script that you have to run for creating an service principal, where you have to enter your SP name, role, and scope:

az ad sp create-for-rbac --name="<ServicePrincipal name>" --role="Contributor" --scopes="/subscriptions/<subscription Id>"

See the following example:

az ad sp create-for-rbac --name="SPForTerraform" --role="Contributor" --scopes="/subscriptions/8921-1444-..."

This sample script creates a new service principal named SPForTerraform and gives it the contributor permission on the subscription ID, 8921....

For more details about the Azure CLI command to create an Azure SP, see the documentation:  https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest.

The following screenshot shows the execution of the script that creates an Azure SP:

The creation of this service principal returns three pieces of identification information:

  • The application ID, also called the client ID
  • The client secret
  • The tenant ID

And the SP is created in Azure AD. The following screenshot shows the Azure AD SP:

Here, we have just seen how to create a service principal in the Azure AD and we have given it the permission to manipulate the resources of our Azure subscriptions.

Now, let's see how to configure Terraform to use our Azure SP.

主站蜘蛛池模板: 石楼县| 桑日县| 高雄市| 新疆| 延川县| 阿坝县| 自治县| 河西区| 南昌县| 兴安县| 深泽县| 静安区| 周宁县| 吴江市| 新密市| 新龙县| 米脂县| 湄潭县| 阿瓦提县| 淮安市| 遵化市| 苍南县| 平潭县| 木兰县| 乌拉特前旗| 柘荣县| 汽车| 英吉沙县| 桐梓县| 修水县| 宝山区| 大方县| 额济纳旗| 陕西省| 崇义县| 长寿区| 九龙县| 高邑县| 通城县| 和平区| 浦城县|