如何使用Azure Resource Manager

时间:2018-02-07 12:13:27

标签: api azure azure-resource-manager azure-api-management

使用门户在Azure API Management Service中创建新API时,您可以指定是否要对API进行版本控制。但是,在使用ARM在Management服务中创建API时,我找不到复制方法。这目前不支持,还是我错过了什么?

我尝试在门户网站中创建版本化API,并将创建的模板与非版本化API的模板进行比较,但看不出差异。

提前致谢。

3 个答案:

答案 0 :(得分:3)

要通过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"
    }
}

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

{
        "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'))]"
        }
    }

答案 1 :(得分:0)

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'))]"
              ]

然后是 api

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

                "properties": {
                    ....

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

答案 2 :(得分:-1)

您可以在路径,标题或查询字符串中指定Azure ARM门户上的版本。但旧的azure API管理门户在构建版本控制中不支持。任何方式都可以在Web API URL后缀中指定版本控制。

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

Azure ARM Portal (New APIM)

Azure APIM Portal (OLD)

谢谢, Infaaz