如何使用使用"contentFormat"将 Shaggerer 从 Arm 模板部署到 Azure API 管理:"swagger-json"



如何使用选项"contentFormat"将swagger从ARM模板部署到Azure API Management: "swagger-json">

https://learn.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2018-06-01-preview/service/apis

    "contentFormat": "swagger-json",
    "contentValue": "D:\tempvsts\APISwagger\APISwagger\swagger.json",

当我运行这个时,我收到以下错误

"消息": "解析错误:在 解析值:D. 路径 '',第 0 行,位置 0。

请注意,我使用了以下选项,它可以工作

"contentFormat": "swagger-link-json",

完整的 ARM 模板

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "ApimServiceName": {
      "type": "string"
    }
  },
  "variables": {
  },
  "resources": [
    {
      "type": "Microsoft.ApiManagement/service/apis",
      "name": "[concat(parameters('ApimServiceName'), '/animalAPI4')]",
      "apiVersion": "2018-06-01-preview",
      "scale": null,
      "properties": {
        "displayName": "HTTP animal API",
        "apiRevision": "1",
        "description": "API Management facade for a very handy and free online HTTP toolsds",
        "serviceUrl": "https://animailhttpbin.org",
        "path": "animals4",
        "contentFormat": "swagger-json",
        "contentValue": "D:\tempvsts\APISwagger\APISwagger\swagger.json",
        "apiVersionSet": {
          "id": "[concat(resourceId('Microsoft.ApiManagement/service', parameters('ApimServiceName')), '/api-version-sets/versionset-animal-api4')]"
        },
        "protocols": [
          "https"
        ],
        "authenticationSettings": null,
        "subscriptionKeyParameterNames": null,
        "apiVersion": "v1"
      },
      "dependsOn": [
      ]
    }
  ]
}

就像提到的 4c74356b41 一样,必须使用作为转义字符串的 JSON 内容值。

你招摇的JSON将是这样的

{ "swagger":"2.0", ... }

所以,它会像这样进入你的 ARM 模板

{
  ...
  "contentFormat": "swagger-json",
  "contentValue": "{ "swagger":"2.0", ... }",
  ...
}

最新更新