如何获取 Azure (ARM) 部署模板的 clientId 和 clientsecret
How to get clientId and clientsecret for Azure (ARM) deployment template
我想自动化我的 Azure 资源管理,我正在使用 ARM 模板来实现。
如果我想从我的 C# 代码(下载 Azure 导出模板时生成的 DeploymentHelper.cs)连接到 Azure。
代码要求提供以下详细信息:
string subscriptionId = "your-subscription-id";
string clientId = "your-service-principal-clientId";
string clientSecret = "your-service-principal-client-secret";
string resourceGroupName = "resource-group-name";
string deploymentName = "deployment-name";
string resourceGroupLocation = "resource-group-location"; // must be specified for creating a new resource group
string pathToTemplateFile = "path-to-template.json-on-disk";
string pathToParameterFile = "path-to-parameters.json-on-disk";
string tenantId = "tenant-id";
我可以通过 powershell 看到 tentantId 和 subscriptionId,但我不知道如何获取 clientId 和 clientsecret,而且我也找不到任何关于如何获取这些的可靠说明。
您是否在 AD 中创建了服务主体?如果是这样,您应该具有这些值。如果还没有,请按照 msft 指南进行操作。
- Azure 门户
- 活动目录
- 应用程序注册(在右侧面板上)
- 单击正确的应用程序(客户端)ID
- 您将在概览中看到。
我想自动化我的 Azure 资源管理,我正在使用 ARM 模板来实现。
如果我想从我的 C# 代码(下载 Azure 导出模板时生成的 DeploymentHelper.cs)连接到 Azure。
代码要求提供以下详细信息:
string subscriptionId = "your-subscription-id";
string clientId = "your-service-principal-clientId";
string clientSecret = "your-service-principal-client-secret";
string resourceGroupName = "resource-group-name";
string deploymentName = "deployment-name";
string resourceGroupLocation = "resource-group-location"; // must be specified for creating a new resource group
string pathToTemplateFile = "path-to-template.json-on-disk";
string pathToParameterFile = "path-to-parameters.json-on-disk";
string tenantId = "tenant-id";
我可以通过 powershell 看到 tentantId 和 subscriptionId,但我不知道如何获取 clientId 和 clientsecret,而且我也找不到任何关于如何获取这些的可靠说明。
您是否在 AD 中创建了服务主体?如果是这样,您应该具有这些值。如果还没有,请按照 msft 指南进行操作。
- Azure 门户
- 活动目录
- 应用程序注册(在右侧面板上)
- 单击正确的应用程序(客户端)ID
- 您将在概览中看到。