Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.2k stars 742 forks source link

APIM cannot set managed certificate without internal error #9650

Closed AnthonyPhan closed 1 year ago

AnthonyPhan commented 1 year ago

Bicep version Bicep CLI version 0.12.40 (41892bd0fb)

Describe the bug When trying to deploy Azure API Management using bicep templates you cannot set a custom domain using the hostNameConfiguration when using a managed certificate. This was previously possible using 2022-04-01-preview but appears to have stopped working.

To Reproduce Steps to reproduce the behavior:

  1. deploy APIM without a host name configuration
  2. Go into the Azure portal and setup a custom domain for your APIM instance
  3. deploy the APIM using the template below, you will get an internal error.

Additional context example bicep template

// Deploy Api Manager instance
param location string = resourceGroup().location

@description('Resource name prefix')
param envResourceNamePrefix string
param apimHostname string
param functionAppUrl string
param tier string = 'consumption'
param capacity int = 0

resource apiManagementInstance 'Microsoft.ApiManagement/service@2022-04-01-preview' = {
  name: '${envResourceNamePrefix}-apim'
  location: location
  sku: {
    capacity: capacity
    name: tier
  }
  properties: {
    virtualNetworkType: 'None'
    publisherEmail: 'support@email'
    publisherName: 'company name'
    hostnameConfigurations: [
      {
        hostName: apimHostname
        type: 'Proxy'
        defaultSslBinding: true
        certificateSource: 'Managed'
      }
    ]
  }
}

resource tfApi 'Microsoft.ApiManagement/service/apis@2021-08-01' = {
  name: 'MyApi'
  parent: apiManagementInstance
  properties: {
    format: 'swagger-json'
    value: loadTextContent('../apiDefinition.swagger.json')
    path: ''
    serviceUrl: functionAppUrl
    subscriptionRequired: false
  }
}
alex-frankel commented 1 year ago

Can you share the complete error message that you are seeing? If you are getting an internal error, it is most likely an issue with the error handling logic in the APIM resource provider. Are you able to open a support ticket so this can be routed to the APIM team?

stephaniezyen commented 1 year ago

No response so closing.