【发布时间】:2018-07-10 17:27:00
【问题描述】:
我有一个 Azure 帐户,我想使用 ASP.NET 库来部署 ARM 模板。我注意到在 Azure 门户生成的 Deployment 类中(在我从门户下载的 DeploymentHelper.cs 文件中)我有以下我需要的字段提供我自己的数据:
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";
string pathToTemplateFile = "path-to-template.json-on-disk";
string pathToParameterFile = "path-to-parameters.json-on-disk";
string tenantId = "tenant-id";
我很难处理这些:
string clientId = "your-service-principal-clientId";
string clientSecret = "your-service-principal-client-secret";
我知道 subscriptionId 我可以在 Subscriptions 刀片中获得。我也知道 tenantId 我可以在 Directory ID 字段下的 Azure Active Directory > Properties 刀片中获取。
我已关注 this documentation page 以尝试在 Azure Active Directory 上设置 App Registration,我已经阅读了获得clientId 和 clientSecret 值。我认为值得一提的是,我对 Active Directory 或 Azure Active Directory 没有任何经验。
当我关注文档时,我的第一个问题是这个刀片:
我不知道应该在“登录 URL”字段中输入什么。我尝试用我的个人网站填充它只是因为它是必需的(可能是我的第一个错误)。然后使用已注册的应用程序,我进入“Application ID”并在我的代码中使用该值作为 clientId。
然后我在“Settings”刀片中生成密钥并将其用作我的代码中的 clientSecret。
但是,当我运行我的代码时,我收到以下错误:
Exception thrown: 'Microsoft.Rest.Azure.CloudException' in System.Private.CoreLib.dll
An exception of type
'Microsoft.Rest.Azure.CloudException' occurred in System.Private.CoreLib.dll but was not handled in user code
Operation returned an invalid status code 'Forbidden'
我不想为了通过 Azure 进行部署而设置任何花哨的 Azure AD。我正在我的个人帐户上尝试此操作,所以它不像设置 AD 环境。
【问题讨论】:
-
您是否为应用程序分配了一个角色,对要在其中部署 ARM 模板的订阅/资源组/资源具有写入权限? docs.microsoft.com/en-us/azure/azure-resource-manager/…
-
嗨@andresm53 是的。那部分很好,所以我什至没有提到它。应该有。
-
@andresm53 你是对的。我做错了那部分,没有给应用程序适当的授权。又做了一次,它奏效了!
标签: azure azure-active-directory azure-resource-manager