Bicep ‘Microsoft.ApiManagement/service@2023-09-01-preview’ Not idempotent

I ran into this issue that running namedvalue bicep twice gave an already exits error. I could not find a solution online, but changing the version to a newer one just solved it!

So from:

resource apim 'Microsoft.ApiManagement/service@2023-09-01-preview' existing = {
  name: apimName
}

resource nm 'Microsoft.ApiManagement/service/namedValues@2023-09-01-preview' = {
  name: namedValueName
  parent: apim

  properties: {
    tags: tags
    displayName: namedValueName
    value: namedValue
    secret: false
  }
}

To:

resource apim 'Microsoft.ApiManagement/service@2024-05-01' existing = {
  name: apimName
}

resource nm 'Microsoft.ApiManagement/service/namedValues@2024-05-01' =  {
  name: namedValueName
  parent: apim

  properties: {
    tags: tags
    displayName: namedValueName
    value: namedValue
    secret: false
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *