是否可以使用Bicep向API添加修订版本?

huangapple go评论85阅读模式
英文:

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'。我的一个实验看起来像是这样:

  1. resource apiManagementBackendApi 'Microsoft.ApiManagement/service/apis@2022-08-01' = {
  2. name: 'somename;rev=2'
  3. parent: apiManagementResourceInstance
  4. properties: {
  5. apiType: 'http'
  6. description: 'Description'
  7. apiRevision: '2'
  8. apiRevisionDescription: 'Changed by bicep'
  9. displayName: 'Some name'
  10. format: 'openapi+json'
  11. path: 'somepath'
  12. protocols: [
  13. 'https'
  14. ]
  15. subscriptionRequired: false
  16. type: 'http'
  17. value: loadTextContent('somefile.json')
  18. }
  19. }
英文:

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:

  1. resource apiManagementBackendApi 'Microsoft.ApiManagement/service/apis@2022-08-01' = {
  2. name: 'somename;rev=2'
  3. parent: apiManagementResourceInstance
  4. properties: {
  5. apiType: 'http'
  6. description: 'Description'
  7. apiRevision: '2'
  8. apiRevisionDescription: 'Changed by bicep'
  9. displayName: 'Some name'
  10. format: 'openapi+json'
  11. path: 'somepath'
  12. protocols: [
  13. 'https'
  14. ]
  15. subscriptionRequired: false
  16. type: 'http'
  17. value: loadTextContent('somefile.json')
  18. }
  19. }

Has someone an idea how to construct a working example?

答案1

得分: 2

我尝试重现了这个问题,但无法。

我猜测您提供的名称/版本与已存在的内容存在一些差异。

以下是我所做的,保持名称和apiRevision一致并没有引发任何问题;

  1. param revision string = '3'
  2. resource apim 'Microsoft.ApiManagement/service@2021-01-01-preview' existing = {
  3. name: apimName
  4. }
  5. resource apimService 'Microsoft.ApiManagement/service/apis@2021-04-01-preview' = {
  6. name: '${servicename};rev=${revision}'
  7. parent: apim
  8. properties: {
  9. path: serviceApimPath
  10. displayName: serviceDisplayName
  11. serviceUrl: baseUrl
  12. protocols: [
  13. 'https'
  14. ]
  15. subscriptionRequired: apimSubscriptionRequired
  16. apiRevision: revision
  17. apiRevisionDescription: 'Updated by bicep'
  18. }
  19. }

是否可以使用Bicep向API添加修订版本?

英文:

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 ;

  1. param revision string = '3'
  2. resource apim 'Microsoft.ApiManagement/service@2021-01-01-preview' existing = {
  3. name: apimName
  4. }
  5. resource apimService 'Microsoft.ApiManagement/service/apis@2021-04-01-preview' = {
  6. name: '${servicename};rev=${revision}'
  7. parent: apim
  8. properties: {
  9. path: serviceApimPath
  10. displayName: serviceDisplayName
  11. serviceUrl: baseUrl
  12. protocols: [
  13. 'https'
  14. ]
  15. subscriptionRequired: apimSubscriptionRequired
  16. apiRevision: revision
  17. apiRevisionDescription: 'Updated by bicep'
  18. }
  19. }

是否可以使用Bicep向API添加修订版本?

huangapple
  • 本文由 发表于 2023年5月24日 18:48:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76322696.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定