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

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.

主站蜘蛛池模板: 浑源县| 福安市| 武定县| 通山县| 葵青区| 珲春市| 太仆寺旗| 南川市| 洪湖市| 英山县| 东平县| 扬中市| 屏南县| 阿拉善左旗| 蛟河市| 贵州省| 隆化县| 古浪县| 团风县| 梅河口市| 宣武区| 萨迦县| 宁乡县| 肥城市| 昌黎县| 九龙县| 甘谷县| 松潘县| 阿巴嘎旗| 同江市| 莎车县| 疏勒县| 仪陇县| 中超| 石嘴山市| 太白县| 维西| 延津县| 上思县| 湘乡市| 呼伦贝尔市|