gpt4 book ai didi

azure - 使用 API 管理服务及其 API 的 ARM 模板进行部署时出现问题

转载 作者:行者123 更新时间:2023-12-02 03:10:43 25 4
gpt4 key购买 nike

我正在尝试使用 ARM 模板部署 Azure API 管理服务及其关联的 API。这里的目标是能够轻松地配置 API 管理服务的新实例及其关联的 API 及其所有设置,但能够使用参数更改后端 URL。为此,我使用 Azure 门户导出了一个模板,并根据我的需要将其更改为能够将后端 url 作为参数传递。但是,我遇到了一些问题:

模板部署返回以下错误:

更新:评论帮助我解决了这个问题。请立即忽略此错误。

16:12:24 - 4:11:50 PM - Resource Microsoft.ApiManagement/service/subscriptions 'testAPITalhaNEW1/master' failed with message '{
16:12:24 - "error": {
16:12:24 - "code": "ValidationError",
16:12:24 - "message": "One or more fields contain incorrect values:",
16:12:24 - "details": [
16:12:24 - {
16:12:24 - "code": "ValidationError",
16:12:24 - "target": "scope",
16:12:24 - "message": "Subscription scope should be one of '/apis', '/apis/{apiId}', '/products/{productId}'"
16:12:24 - }
16:12:24 - ]
16:12:24 - }
16:12:24 - }'
16:12:24 - 4:11:50 PM - Subscription scope should be one of '/apis', '/apis/{apiId}', '/products/{productId}'
16:12:24 - 4:12:01 PM - Resource Microsoft.ApiManagement/service/groups/users 'testAPITalhaNEW1/administrators/1' failed with message '{
16:12:24 - "error": {
16:12:24 - "code": "MethodNotAllowed",
16:12:24 - "message": "System group membership cannot be changed",
16:12:24 - "details": null
16:12:24 - }
16:12:24 - }'
16:12:24 - 4:12:01 PM - Resource Microsoft.ApiManagement/service/groups/users 'testAPITalhaNEW1/developers/1' failed with message '{
16:12:24 - "error": {
16:12:24 - "code": "MethodNotAllowed",
16:12:24 - "message": "System group membership cannot be changed",
16:12:24 - "details": null
16:12:24 - }
16:12:24 - }'
16:12:24 - 4:12:01 PM - Resource Microsoft.ApiManagement/service/users 'testAPITalhaNEW1/1' failed with message '{
16:12:24 - "error": {
16:12:24 - "code": "MethodNotAllowed",
16:12:24 - "message": "Cannot modify property for user with built-In role",
16:12:24 - "details": null
16:12:24 - }
16:12:24 - }'



最初的行是:

        "scope": "[concat(resourceId('Microsoft.ApiManagement/master', parameters('service_testAPITalha_name')), '/')]",

我改为:

        "scope": "[concat(resourceId('Microsoft.ApiManagement/apis', parameters('service_testAPITalha_name')), '/')]",

这也没有解决问题。

错误:“订阅范围应为“/apis”、“/apis/{apiId}”、“/products/{productId}”之一”

    {
"type": "Microsoft.ApiManagement/service/subscriptions",
"apiVersion": "2019-01-01",
"name": "[concat(parameters('service_testAPITalha_name'), '/master')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service', parameters('service_testAPITalha_name'))]"
],
//Changed from master to apis
"properties": {
"scope": "[concat(resourceId('Microsoft.ApiManagement/apis', parameters('service_testAPITalha_name')), '/')]",
"displayName": "Built-in all-access subscription",
"state": "active",
"primaryKey": "a4a0311b7af34f8fad57cdf8e06723fb",
"secondaryKey": "3bfb52667eb443a0a430e298b402da03",
"allowTracing": true
}
}

错误:MethodNotAllowed:“无法修改具有内置角色的用户的属性”

 {
"type": "Microsoft.ApiManagement/service/users",
"apiVersion": "2019-01-01",
"name": "[concat(parameters('service_testAPITalha_name'), '/1')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service', parameters('service_testAPITalha_name'))]"
],
"properties": {
"firstName": "Administrator",
"email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="047c7c7c446c6b7069656d682a676b69" rel="noreferrer noopener nofollow">[email protected]</a>",
"state": "active",
"identities": [
{
"provider": "Azure",
"id": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a6262625a72756e777b737634797577" rel="noreferrer noopener nofollow">[email protected]</a>"
}
],
"lastName": "[parameters('users_1_lastName')]"
}
}

我取出的电子邮件是注册 Azure 帐户的主电子邮件...

如果我删除这段代码,我会遇到更多关于找不到资源的错误,因此我相信我的 ARM 模板中存在对这段特定代码/资源的依赖性。

这里的最终目标是能够使用 ARM 模板轻松地从开发到测试、过渡到生产,并保持 API 管理服务及其 API 的所有内容完好无损,并且只需更改后端 URL。我相信我已经快到了,只是想调试这个脚本,任何帮助将不胜感激!!

最佳答案

我遇到了同样的问题,但已经解决了。您很可能已经根据“导出模板”功能生成了 ARM 模板?

这将生成两个“默认”订阅和一个默认用户(管理员)。删除所有三个,您的模板应该可以正常运行。管理员的“Starter”和“Unlimited”订阅始终是在没有 ARM 模板说明的情况下创建的。

因此,删除 Microsoft.ApiManagement/service/users 部分:

"[concat(parameters('service_testAPITalha_name'), '/1')]"

以及两个订阅部分,其中包含:

"ownerId": "[resourceId('Microsoft.ApiManagement/service/users', parameters('service_testAPITalha_name'), '1')]",
"scope": "[resourceId('Microsoft.ApiManagement/service/products', parameters('service_testAPITalha_name'), 'starter')]

和:

"ownerId": "[resourceId('Microsoft.ApiManagement/service/users', parameters('service_testAPITalha_name'), '1')]",
"scope": "[resourceId('Microsoft.ApiManagement/service/products', parameters('service_testAPITalha_name'), 'unlimited')]

关于azure - 使用 API 管理服务及其 API 的 ARM 模板进行部署时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57666000/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com