Azure API 管理架构 ARM 模板导入错误
Azure API Management Schema ARM Template import error
我的 ARM 模板中定义了以下架构:
{
"name": "[concat(variables('api-v1-operation-prefix'), '/', variables('schema-v1-report-name'))]",
"type": "Microsoft.ApiManagement/service/apis/schemas",
"apiVersion": "2018-01-01",
"properties": {
"contentType": "application/json",
"document": {
"value": "[concat('{\r\n \"', variables('schema-v1-report-name'), '\": {\r\n \"type\": \"object\",\r\n \"required\": [\r\n \"Email\",\r\n \"LastName\",\r\n \"Zip\",\r\n \"Subject\",\r\n \"Message\",\r\n \"CategoryId\",\r\n \"SubcategoryId\",\r\n \"RequestTypeInt\"\r\n ],\r\n \"properties\": {\r\n \"FirstName\": {\r\n \"type\": \"string\"\r\n },\r\n \"LastName\": {\r\n \"type\": \"string\"\r\n },\r\n \"Email\": {\r\n \"type\": \"string\"\r\n },\r\n \"Phone\": {\r\n \"type\": \"string\"\r\n },\r\n \"Zip\": {\r\n \"type\": \"string\"\r\n },\r\n \"Subject\": {\r\n \"type\": \"string\"\r\n },\r\n \"Message\": {\r\n \"type\": \"string\"\r\n },\r\n \"CategoryId\": {\r\n \"type\": \"string\"\r\n },\r\n \"SubcategoryId\": {\r\n \"type\": \"string\"\r\n },\r\n \"RequestTypeInt\": {\r\n \"type\": \"number\"\r\n },\r\n \"WantsEmailResponse\": {\r\n \"type\": \"boolean\"\r\n }\r\n }\r\n }\r\n}')]"
}
}
}
当我部署 ARM 模板时,架构没有正确导入,我在 Azure 门户的 OpenAPI 规范视图中看到以下错误:
x-ms-export-notes:
- >-
The exported API contains schemas that aren't of content type
'application/vnd.ms-azure-apim.swagger.definitions+json', and are hence not
exported as Swagger definitions.
我遵循了基于 Joy Wang 的 link 的 ARM 模板。这使我完成了 90% 的工作。问题是,对于每个操作的 schemaId,我使用了定义名称(或类型名称),但它应该是模式资源的 ID。
我的 ARM 模板中定义了以下架构:
{
"name": "[concat(variables('api-v1-operation-prefix'), '/', variables('schema-v1-report-name'))]",
"type": "Microsoft.ApiManagement/service/apis/schemas",
"apiVersion": "2018-01-01",
"properties": {
"contentType": "application/json",
"document": {
"value": "[concat('{\r\n \"', variables('schema-v1-report-name'), '\": {\r\n \"type\": \"object\",\r\n \"required\": [\r\n \"Email\",\r\n \"LastName\",\r\n \"Zip\",\r\n \"Subject\",\r\n \"Message\",\r\n \"CategoryId\",\r\n \"SubcategoryId\",\r\n \"RequestTypeInt\"\r\n ],\r\n \"properties\": {\r\n \"FirstName\": {\r\n \"type\": \"string\"\r\n },\r\n \"LastName\": {\r\n \"type\": \"string\"\r\n },\r\n \"Email\": {\r\n \"type\": \"string\"\r\n },\r\n \"Phone\": {\r\n \"type\": \"string\"\r\n },\r\n \"Zip\": {\r\n \"type\": \"string\"\r\n },\r\n \"Subject\": {\r\n \"type\": \"string\"\r\n },\r\n \"Message\": {\r\n \"type\": \"string\"\r\n },\r\n \"CategoryId\": {\r\n \"type\": \"string\"\r\n },\r\n \"SubcategoryId\": {\r\n \"type\": \"string\"\r\n },\r\n \"RequestTypeInt\": {\r\n \"type\": \"number\"\r\n },\r\n \"WantsEmailResponse\": {\r\n \"type\": \"boolean\"\r\n }\r\n }\r\n }\r\n}')]"
}
}
}
当我部署 ARM 模板时,架构没有正确导入,我在 Azure 门户的 OpenAPI 规范视图中看到以下错误:
x-ms-export-notes: - >- The exported API contains schemas that aren't of content type 'application/vnd.ms-azure-apim.swagger.definitions+json', and are hence not exported as Swagger definitions.
我遵循了基于 Joy Wang 的 link 的 ARM 模板。这使我完成了 90% 的工作。问题是,对于每个操作的 schemaId,我使用了定义名称(或类型名称),但它应该是模式资源的 ID。