Rabbitmq on azure container app error 405 on trying to create queue on web management

Pedro Miranda 5 Reputation points
2024-03-25T20:34:18.8033333+00:00

I'm trying to create a bicep file for an application that uses RabbitMQ. However, the RabbitMQ container app throws an error when I try to create a queue or an exchange. I'm able to create a queue and add messages with a Python script, but when I try to open the queue on the web, it says it doesn't exist.

Error when I try to create a new queue

I belive the error is thanks to the %2F on the url of rabbitmq, but I´m not sure.I belive the error is thanks to the %2F on the url of rabbitmq

Bicep file:

resource vnet 'Microsoft.Network/virtualNetworks@2023-06-01' = {
  name: '${prefix}-vnet'
  location: location
  properties: {
    addressSpace: {
      addressPrefixes: ['10.2.0.0/16']
    }
    encryption: {
      enabled: false
      enforcement: 'AllowUnencrypted'
    }
    virtualNetworkPeerings: []
    enableDdosProtection: false
  }
}

resource Subnet_rabbitmq 'Microsoft.Network/virtualNetworks/subnets@2023-06-01' = {
  parent: vnet
  name: 'subnet-rabbitmq'
  properties: {
    addressPrefix: '10.2.2.0/23'
    // networkSecurityGroup: {
    //   id: networkSecurityGroup.id
    // }
    serviceEndpoints: []
    // delegations: [
    //   {
    //     name: 'Microsoft.App.environments'
    //     properties: {
    //       serviceName: 'Microsoft.App/environments'
    //     }
    //     type: 'Microsoft.Network/virtualNetworks/subnets/delegations'
    //   }
    // ]
    privateEndpointNetworkPolicies: 'Disabled'
    privateLinkServiceNetworkPolicies: 'Enabled'
  }
}

resource managedEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' = {
  name: 'env-${prefix}'
  location: location
  properties: {
    daprAIInstrumentationKey:appInsights.properties.InstrumentationKey
    appLogsConfiguration: {
      destination: 'log-analytics'
      logAnalyticsConfiguration: {
        customerId: logAnalyticsWorkspace.properties.customerId
        sharedKey: logAnalyticsWorkspace.listKeys().primarySharedKey
      }
    }
    // vnetConfiguration:{
    //   infrastructureSubnetId: resourceId('Microsoft.Network/virtualNetworks/subnets', vnet.name, 'rabbitmq')
    //  }
    vnetConfiguration: {
      internal: false
      infrastructureSubnetId: Subnet_rabbitmq.id
    }
  }
}

resource containerAppRabbitmq 'Microsoft.App/containerapps@2023-08-01-preview' ={
  name: 'ca-${prefix}-rabbitmq'
  location: location
  properties:{
    managedEnvironmentId: managedEnvironment.id
    environmentId: managedEnvironment.id
    // workloadProfileName: 'Consumption'
    configuration: {
      secrets: [
        {
          name: 'containerregistrypasswordref'
          value: 'password'
        }
      ]
      activeRevisionsMode: 'Single'
      ingress: {
        external: true
        targetPort: 15672
        exposedPort: 0
        transport: 'Auto'
        traffic: [
          {
            weight: 100
            latestRevision: true
          }
        ]
        allowInsecure: true
        clientCertificateMode: 'Ignore'
        stickySessions: {
          affinity: 'none'
        }
        additionalPortMappings: [
          {
            external: true
            targetPort: 5672
            exposedPort: 5672
          }
        ]
      }
      registries: [
        {
          // server is in the format of myregistry.azurecr.io
          server: '{acr-url}'
          username: 'test-bicep'
          passwordSecretRef: 'containerregistrypasswordref'
        }
      ]
    }
    template: {
      containers: [
        {
          image: '{acr-url}/external/rabbitmq:3.11-management'
          name: 'rabbitmq-3-11-management'
        }
      ]
    }
  }
}

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
324 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Pedro Miranda 5 Reputation points
    2024-04-22T17:39:49.42+00:00

    Looks like ACA uses nginx and it blocks the "/" of the urls, and turns out the rabbitmq default virtual host is "/", causing this issue.

    Changing the default vhost for rabbitmq solved the problem, just add this variable as example:

                {
                name: 'RABBITMQ_DEFAULT_VHOST'
                value: 'my_vhost'
                }
    
    0 comments No comments