Specify the Node Resource Group Name for an Azure Container Apps Environment in Bicep

70 views Asked by At

I want to host a container app on Azure and I'm using Bicep to define the deployment. When I deployed the app, I was surprised to find another resource group named MC_{lots-of-random-text}_westeurope where all the expensive stuff (kubernetes, public IPs) was stored.

I'm not happy with this outcome, I would much rather have everything in one resource group, but at least I learned that this is a node resource group and Azure does not want to give me container apps without one. But can I at least give a more useful name to the node resource group? The documentation says it should be MC_myResourceGroup_myAKSCluster_eastus, but in my case, the name is just random garbage.

I tried to specify a infrastructureResourceGroup for the container app environment, but that didn't work, I just got another random name.

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
  name: containerAppEnvName
  location: location
  properties: {
    infrastructureResourceGroup: 'actually-useful-name'
    appLogsConfiguration: ...
    vnetConfiguration: ...
  }
}

How can I specify a custom name for the node resource group in my bicep template? Or better yet, deploy a docker container without the need for a separate node resource group?

1

There are 1 answers

2
Jahnavi On

Specify the Node Resource Group Name for an Azure Container Apps Environment in Bicep:

According to the MS Doc, infrastructureResourceGroup property from ManagedEnvironmentProperties of app managed environments resource will be used to provide name of a managed resource group created of the Managed Environment to host infrastructure resources.

Try with the latest Api version which is 2023-08-01-preview. I tried same in my environment and was able to deploy it as expected.

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-08-01-preview' = {
  name: containerAppEnvName
  location: location 
  properties: {
    appLogsConfiguration: {
      destination: 'log-analytics'
      logAnalyticsConfiguration: {
        customerId: logAnalytics.properties.customerId
        sharedKey: logAnalytics.listKeys().primarySharedKey
      }
    }
    infrastructureResourceGroup: 'xxxx'
  }
}

enter image description here

Alternatively, you can also control the resource group creation from where your cluster is deployed. Use resource group and location properties to achieve that.

Microsoft.ContainerService/managedClusters