繁体   English   中英

我如何设置我的Azure帐户以通过REST API进行ARM部署?

[英]How can I set up my Azure account in order to make ARM deployments via the REST API?

我有一个Azure帐户,我想使用ASP.NET库进行ARM模板的部署。 我注意到,在Azure Portal生成的Deployment类中(在我从Portal下载的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 我也知道可以在“ 目录ID”字段下的“ Azure Active Directory”>“属性”刀片中获得的tenantId

我已遵循此文档页面 ,以尝试在Azure Active Directory上设置应用程序注册 ,我已阅读该文件 ,以获得cliendIdclientSecret值。 我认为值得一提的是,我对Active DirectoryAzure Active Directory毫无经验。

当遵循文档时,我的第一个问题是关于此刀片的:

在此处输入图片说明

我不知道应该在“ 登录URL ”字段中输入什么。 我试图用我的个人网站填充它只是因为它是必需的(可能是我的第一个错误)。 然后,使用已注册的应用程序,进入“ 应用程序ID ”,并在代码中使用该值作为clientId

然后,我在“ 设置 ”刀片中生成密钥,并将其用作代码中的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 AD设置以便通过Azure进行部署。 我正在用我的个人帐户尝试此操作,因此这与设置AD环境不同。

我不知道应该在“登录URL”字段中输入什么。 我试图用我的个人网站填充它只是因为它是必需的(可能是我的第一个错误)。

如果开发Web应用程序,则可以将Web应用程序作为登录URL进行寻址。 根据您的情况,您可以添加无效的网址。 您可以添加您的个人网站。

操作返回了无效的状态码“禁止”

这意味着您无权将资源部署到订阅。

您需要将角色提升到WebApplication。 有关更多信息,请参考如何注册Azure AD应用程序和助理角色

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM