microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
372 stars 29 forks source link

infrastructureResourceGroup is null #1323

Open vc2023 opened 1 month ago

vc2023 commented 1 month ago

The issue is related to the following #1118 issue, which was closed. Below is my bicep module which still returns Null. What am I doing wrong? Maybe workload profile is wrong?

param location string = resourceGroup().location
param tags object
param infrastructureSubnetId string
param name string
param logAnalyticsWorkspaceName  string
param infrastructureResourceGroup string

resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' existing = {
  name: logAnalyticsWorkspaceName
}

resource managedEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
  name: name
  location: location
  tags: tags
  //kind: 'string'
  properties: {
    appLogsConfiguration: {
      destination: 'log-analytics'
      logAnalyticsConfiguration: {
        customerId: logAnalytics.properties.customerId
        sharedKey: logAnalytics.listKeys().primarySharedKey
      }
    }
    infrastructureResourceGroup: infrastructureResourceGroup
    vnetConfiguration: {
      //dockerBridgeCidr: 'string'
      //infrastructureSubnetId: infrastructureSubnetId
      internal: false
      // platformReservedCidr: 'string'
      // platformReservedDnsIP: 'string'
    }
    workloadProfiles: [
      {
        maximumCount: 5
        minimumCount: 1
        name: 'D4'
        workloadProfileType: 'D4'
      }
    ]
    // zoneRedundant: bool
  }
}

output managedEnvironmentId string = managedEnvironment.id
output staticIp string = managedEnvironment.properties.staticIp
output name string = managedEnvironment.name
output infrastructureResourceGroup string = managedEnvironment.properties.infrastructureResourceGroup
v-vish commented 3 weeks ago

@vc2023 Could you please provide more context on the objective of this setup? I noticed that the infrastructureSubnetId parameter is currently commented out in your Bicep file (//infrastructureSubnetId: infrastructureSubnetId).

Would you be able to try uncommenting this line to enable the infrastructureSubnetId and test if it addresses the configuration requirements? Let us know the outcome,

vc2023 commented 3 weeks ago

Hi @v-vish yes infrastructureSubnetId is currently commented, in order to run the deployment quicker. I don't think I need networking in order to be able to set/get infrastructureResourceGroup, do I? I just want to be able to set the infrastructureResourceGroup: infrastructureResourceGroup property. And then I want to gt the infrastructureResourceGroup as output parameter output infrastructureResourceGroup string = managedEnvironment.properties.infrastructureResourceGroup

I just want to use this output parameter for the next step/module as input parameter in deployment process in order to get the internal load balancer.

module lbi 'services/load-balancer.bicep' = {
  name:'lbi--${envName}'
  params:{
    infrastructureResourceGroup:containerAppEnvironmentInternal.outputs.infrastructureResourceGroup
  }
}
param infrastructureResourceGroup string
resource lbi 'Microsoft.Network/loadBalancers@2023-09-01' existing = {
  name:'kubernetes-internal'
  scope:resourceGroup(infrastructureResourceGroup)
}

output loadBalancerFipId string = lbi.properties.frontendIPConfigurations[0].id

But I get the following error {"code":"DeploymentOutputEvaluationFailed","target":"/subscriptions/9e3423d5-9fb5-4d91-a647-edf09b1bfc82/resourceGroups/rg-carat-platform-dev/providers/Microsoft.Resources/deployments/container-app-environment-dev-internal","message":"Unable to evaluate template outputs: 'infrastructureResourceGroup'. Please see error details and deployment operations. Please see https://aka.ms/arm-common-errors for usage details.","details":[{"code":"DeploymentOutputEvaluationFailed","target":"infrastructureResourceGroup","message":"The template output 'infrastructureResourceGroup' is not valid: The provided value for the template output 'infrastructureResourceGroup' is not valid. Expected a value of type 'String, Uri', but received a value of type 'Null'. Please see https://aka.ms/arm-create-parameter-file for usage details.."}]}