如何使用 Azure 资源管理器在 Azure API 管理中对 API 进行版本控制

How to version an API in Azure API Management using Azure Resource Manager

使用门户在 Azure API 管理服务中创建新的 API 时,您可以指定是否要对 API 进行版本控制。但是,在使用 ARM 的管理服务中创建 API 时,我找不到复制它的方法。目前不支持此功能,还是我遗漏了什么?

我已经尝试在门户中创建版本化 API 并将创建的模板与非版本化 API 的模板进行比较,但看不出有什么不同。

提前致谢。

您可以在路径中指定 Azure ARM 门户上的版本,header 或作为查询 string.But 构建中不支持旧的 azure API 管理门户 versioning.Any您可以在 Web API URL 后缀中指定版本控制的方式。

不过,如果您有任何问题,请添加一些图片并描述您的问题。

Azure ARM Portal (New APIM)

Azure APIM Portal (OLD)

谢谢, 因法兹

要通过 ARM 脚本实现此目的,您需要先创建一个 ApiVersionSet 资源:

{
    "name": "[concat(variables('ManagementServiceName'), '/', variables('VersionSetName'))]",
    "type": "Microsoft.ApiManagement/service/api-version-sets",
    "apiVersion": "2017-03-01",
    "properties": {
        "description": "Api Description",
        "displayName": "Api Name",
        "versioningScheme": "Segment"
    }
}

然后在 Microsoft.ApiManagement/service/apis 资源上更新 apiVersionSetId 属性:

{
        "type": "Microsoft.ApiManagement/service/apis",
        "name": "[concat(variables('ManagementServiceName'), '/', variables('ApiName'))]",
        "apiVersion": "2017-03-01",
        "dependsOn": [
            "[resourceId('Microsoft.ApiManagement/service/api-version-sets', variables('ManagementServiceName'), variables('VersionSetName'))]"
        ],
        "properties": {
            "displayName": "string",
            "apiRevision": "1",
            "description": "",
            "serviceUrl": "string",
            "path": "string",
            "protocols": [
                "https"
            ],
            "isCurrent": true,
            "apiVersion": "v1",
            "apiVersionName": "v1",
            "apiVersionDescription": "string",
            "apiVersionSetId": "[concat('/api-version-sets', variables('VersionSetName'))]"
        }
    }

api版本集

的资源
              "name": "my-api-version-sets",
              "type": "api-version-sets",
              "apiVersion": "2018-01-01",
              "properties": {
                "displayName": "Provider API",
                "versioningScheme": "Segment"
              },
              "dependsOn": [
                "[concat('Microsoft.ApiManagement/service/', variables('apiManagementServiceName'))]"
              ]

然后 apis

                "apiVersion": "2018-01-01",
                "type": "apis",

                "properties": {
                    ....

                    "isCurrent": true,
                    "apiVersion": "v1",
                    "apiVersionSetId": "/api-version-sets/my-api-version-sets"