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

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

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'
  }
}

是否可以使用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 ;

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'
  }
}

是否可以使用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:

确定