英文:
Is it possible to add a revision to an API using Bicep?
问题
我试图使用 Bicep 添加一个新的版本,使用的资源是 'Microsoft.ApiManagement/service/apis@2022-08-01',但是我收到了验证错误,比如 'Can't change property Name for non-current revision' 和 'API with specified name ... already exists'。我的一个实验看起来像是这样:
resource apiManagementBackendApi 'Microsoft.ApiManagement/service/apis@2022-08-01' = {
name: 'somename;rev=2'
parent: apiManagementResourceInstance
properties: {
apiType: 'http'
description: 'Description'
apiRevision: '2'
apiRevisionDescription: 'Changed by bicep'
displayName: 'Some name'
format: 'openapi+json'
path: 'somepath'
protocols: [
'https'
]
subscriptionRequired: false
type: 'http'
value: loadTextContent('somefile.json')
}
}
英文:
I'm tried to add a new revision using Bicep using the resource 'Microsoft.ApiManagement/service/apis@2022-08-01' but I get validation errors like 'Can't change property Name for non-current revision' and 'API with specified name ... already exists'. One of my experiments looked like something like this:
resource apiManagementBackendApi 'Microsoft.ApiManagement/service/apis@2022-08-01' = {
name: 'somename;rev=2'
parent: apiManagementResourceInstance
properties: {
apiType: 'http'
description: 'Description'
apiRevision: '2'
apiRevisionDescription: 'Changed by bicep'
displayName: 'Some name'
format: 'openapi+json'
path: 'somepath'
protocols: [
'https'
]
subscriptionRequired: false
type: 'http'
value: loadTextContent('somefile.json')
}
}
Has someone an idea how to construct a working example?
答案1
得分: 2
我尝试重现了这个问题,但无法。
我猜测您提供的名称/版本与已存在的内容存在一些差异。
以下是我所做的,保持名称和apiRevision一致并没有引发任何问题;
param revision string = '3'
resource apim 'Microsoft.ApiManagement/service@2021-01-01-preview' existing = {
name: apimName
}
resource apimService 'Microsoft.ApiManagement/service/apis@2021-04-01-preview' = {
name: '${servicename};rev=${revision}'
parent: apim
properties: {
path: serviceApimPath
displayName: serviceDisplayName
serviceUrl: baseUrl
protocols: [
'https'
]
subscriptionRequired: apimSubscriptionRequired
apiRevision: revision
apiRevisionDescription: 'Updated by bicep'
}
}
英文:
Tried repro'ing the issue but can't.
I'm going to guess there's some disparity in the name/revision that your are supplying with what already existing.
Here's what I did, keeping the name and apiRevision consistent didn't cause any problems ;
param revision string = '3'
resource apim 'Microsoft.ApiManagement/service@2021-01-01-preview' existing = {
name: apimName
}
resource apimService 'Microsoft.ApiManagement/service/apis@2021-04-01-preview' = {
name: '${servicename};rev=${revision}'
parent: apim
properties: {
path: serviceApimPath
displayName: serviceDisplayName
serviceUrl: baseUrl
protocols: [
'https'
]
subscriptionRequired: apimSubscriptionRequired
apiRevision: revision
apiRevisionDescription: 'Updated by bicep'
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论