azure - API管理ARM模板创建

标签 azure azure-api-management azure-rm-template

我在 ARM 模板中定义了此资源,使用单个 API、单个操作,但是当我部署模板时,它不包含该 API。我错过了什么?

   {
      "apiVersion": "2017-03-01",
      "name": "[variables('am-apimanagement-service-name')]",
      "type": "Microsoft.ApiManagement/service",
      "location": "North Europe",
      "tags": {},
      "sku": {
        "name": "[parameters('am-sku')]",
        "capacity": "[parameters('am-skuCount')]"
      },
      "properties": {
        "publisherEmail": "[parameters('am-publisher-email-p')]",
        "publisherName": "[parameters('am-publisher-name-p')]",
        "resources": [
          {
            "type": "Microsoft.ApiManagement/service/apis",
            "apiVersion": "2017-03-01",
            "name": "testapi",
            "dependsOn": [
              "[concat('Microsoft.ApiManagement/service',variables('am-apimanagement-service-name'))]"
            ],
            "properties": {
              "displayName": "TestApi",
              "description": "",
              "serviceUrl": "https://testdevsite.azurewebsites.net",
              "path": "testpath",
              "protocols": [
                "https"
              ],
              "authenticationSettings": null,
              "subscriptionKeyParameterNames": null,
              "isCurrent": true,
              "apiVersion": null,
              "resources": [
                {
                  "apiVersion": "2017-03-01",
                  "type": "operations",
                  "name": "GetOperation",
                  "dependsOn": [
                    "[concat('Microsoft.ApiManagement/service/', variables('am-apimanagement-service-name'), '/apis/testapi')]"
                  ],
                  "properties": {
                    "displayName": "GET",
                    "method": "GET",
                    "urlTemplate": "/resource",
                    "description": "Get"
                  }
                }
              ]
            }
          }
        ]
      }
    }

它很好地创建了 API 管理资源,但它不包括我的 API。

我一定配置有问题,我只是看不到它。

基本上我想要的是一个调用位于同一资源组中的 Web API 的 API。

最佳答案

这里缺少的部分是我无法理解子资源被放置在属性下这个简单的事实。当这个问题被纠正后,一切都很好:

   {
      "apiVersion": "2017-03-01",
      "name": "[variables('am-apimanagement-service-name')]",
      "type": "Microsoft.ApiManagement/service",
      "location": "North Europe",
      "sku": {
        "name": "[parameters('am-sku')]",
        "capacity": "[parameters('am-skuCount')]"
      },
      "properties": {
        "publisherEmail": "[parameters('am-publisher-email-p')]",
        "publisherName": "[parameters('am-publisher-name-p')]"
      },
      "resources": [
        {
          "type": "apis",
          "apiVersion": "2017-03-01",
          "name": "test",
          "dependsOn": [
            "[concat('Microsoft.ApiManagement/service/',variables('am-apimanagement-service-name'))]"
          ],
          "properties": {
            "displayName": "test",
            "description": "",
            "serviceUrl": "[concat('https://test-webapi-',parameters('environment'),'.azurewebsites.net')]",
            "path": "test",
            "protocols": [
              "https"
            ],
            "isCurrent": true
          },
          "resources": [
            {
              "apiVersion": "2017-03-01",
              "type": "operations",
              "name": "Get",
              "dependsOn": [
                "[concat('Microsoft.ApiManagement/service/', variables('am-apimanagement-service-name'), '/apis/test')]"
              ],
              "properties": {
                "displayName": "GET",
                "method": "GET",
                "urlTemplate": "/api/sites",
                "description": "Get"
              }
            }
          ]

        }
      ]
    }

关于azure - API管理ARM模板创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50152209/

相关文章:

azure - Function App 使用除 MS 文档所述之外的其他出站 IP 地址

c - 是否可以从非托管 C(ZigBee 设备)调用 WCF 4.0(SOAP 或 REST)?

azure - Azure 中 Linux 容器中 Katalon 的 Docker 命令

asp.net - HttpRuntime.Cache 在 Windows Azure 上的高负载下损坏数据

azure - 在Azure API管理中,是否可以有一个允许斜杠(例如路径)的模板参数?

azure - 如何在 APIM 中添加绑定(bind)处理策略?

azure - 如何动态更新 Azure APIM 中的后端/出站 URL

windows - 将参数传递到 Azure ARM 模板

azure ARM "code": "InUseSubnetCannotBeDeleted" when trying to update vnet

azure - ARM 创建嵌套管理组