使用门户网站在Azure API管理服务中创建新的API时,您可以指定是否希望API版本。但是,在使用ARM在管理服务中创建API时,我找不到一种复制此方法的方法。这是当前不支持的,还是我缺少某些东西?
我尝试在门户网站中创建版本的API,并将创建的模板与非反复API的模板进行比较,但看不到差异。
预先感谢。
要通过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 version-sets
的资源 "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"
您可以在路径,标题或查询字符串中的Azure Arm Portal上指定版本。但是,旧的Azure API管理门户不支持构建版本,您可以指定版本来指定版本操作在Web API URL后缀中。
如果您有任何问题,请添加一些图像并描述您的问题。
Azure Arm Portal(新APIM(
azure apim门户(旧(
谢谢Infaaz