简体   繁体   English

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

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

I have an Azure accounts and I want to make deployment of ARM templates using the ASP.NET libraries. 我有一个Azure帐户,我想使用ASP.NET库进行ARM模板的部署。 I've noticed that in the Azure Portal generated Deployment class (in the DeploymentHelper.cs file that I've downloaded from the Portal) I have the following fields that I need to provide my own data: 我注意到,在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";

I'm having a hard time with these: 我在这些方面遇到了困难:

string clientId = "your-service-principal-clientId";
string clientSecret = "your-service-principal-client-secret";

I know that the subscriptionId I can get in the Subscriptions blade. 我知道可以在“ 订阅”刀片中获得的subscriptionId I also know that the tenantId I can get in the Azure Active Directory > Properties blade under the Directory ID field. 我也知道可以在“ 目录ID”字段下的“ Azure Active Directory”>“属性”刀片中获得的tenantId

I have followed this documentation page in order to try and set up an App Registration on Azure Active Directory , which I've read is what I need to obtain the cliendId and clientSecret values. 我已遵循此文档页面 ,以尝试在Azure Active Directory上设置应用程序注册 ,我已阅读该文件 ,以获得cliendIdclientSecret值。 I think it's worth mentioning I have no experience whatsoever with Active Directory or Azure Active Directory . 我认为值得一提的是,我对Active DirectoryAzure Active Directory毫无经验。

When following the docs my first issue is with this blade: 当遵循文档时,我的第一个问题是关于此刀片的:

在此处输入图片说明

I don't know what I should put in the " Sign-on URL " field. 我不知道应该在“ 登录URL ”字段中输入什么。 I've tried filling it with my personal website just because it's required (probably my first mistake). 我试图用我的个人网站填充它只是因为它是必需的(可能是我的第一个错误)。 Then with the Registered App I go in " Application ID " and use the value as clientId within my code. 然后,使用已注册的应用程序,进入“ 应用程序ID ”,并在代码中使用该值作为clientId

I then generate the key in the " Settings " blade and use it as the clientSecret within my code. 然后,我在“ 设置 ”刀片中生成密钥,并将其用作代码中的clientSecret

However when I run my code I get the following error: 但是,当我运行代码时,出现以下错误:

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'

I wouldn't want to do any fancy Azure AD set up in order to make deployments via Azure. 我不想进行任何精美的Azure AD设置以便通过Azure进行部署。 I'm trying this on my personal account, so it's not like a have an AD environment set up. 我正在用我的个人帐户尝试此操作,因此这与设置AD环境不同。

I don't know what I should put in the "Sign-on URL" field. 我不知道应该在“登录URL”字段中输入什么。 I've tried filling it with my personal website just because it's required (probably my first mistake). 我试图用我的个人网站填充它只是因为它是必需的(可能是我的第一个错误)。

If you develop a WebApplication, you could Webapplication address it as sign-on url. 如果开发Web应用程序,则可以将Web应用程序作为登录URL进行寻址。 In your case your could add a vaild url address. 根据您的情况,您可以添加无效的网址。 And you could add your personal website. 您可以添加您的个人网站。

Operation returned an invalid status code 'Forbidden' 操作返回了无效的状态码“禁止”

It means that you have no access to deploy the resource to the subscription. 这意味着您无权将资源部署到订阅。

You need to assgin role to the WebApplication. 您需要将角色提升到WebApplication。 For more information, refer to how to registry an Azure AD application and assigin role . 有关更多信息,请参考如何注册Azure AD应用程序和助理角色

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

相关问题 可以通过 REST API 交换 Azure Web 应用部署槽吗? - Can Azure web app deployments slots be swapped via the REST API? 如何为“Azure REST API”设置 IP 限制? - How can I set up IP restrictions for "Azure REST API"? 如何设置我的 Linux Azure VM 以便我可以通过浏览器连接? - How do I set up my Linux Azure VM so that I can connect via a browser? 在Azure中使用基于角色的授权时,如何允许服务帐户访问REST API? - How can I allow a service account to access my REST API when using Roles-based Authorization in Azure? 如何在具有不同 timedelta 的 Azure 批处理帐户中设置我的作业计划? - How do i set up my job schedule in Azure batch account with different timedelta? 如何使用ARM模板为我的Azure Web应用程序设置“仅限Https”? - How can I set “Https only” for my Azure web app using an ARM template? 通过 Azure ARM Rest ZDB974238714CA38DE634A7CE10ZF 创建机器人连接 - Creating a bot connection via Azure ARM Rest API Azure - 通过 ARM REST api 从注册表运行二头肌 - Azure - Run bicep from registry via ARM REST api 如何为在 Azure 存储帐户中创建新容器设置警报? - How can I set up an alert for the creation of a new container in an Azure Storage Account? 如何让 Azure 中的 API 与服务通信? - How can I make my API in Azure communicate with a service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM