microsoft / azure-container-apps

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

Failed to create Container Apps Environment with custom virtual network #451

Open pbakun opened 2 years ago

pbakun commented 2 years ago

Please provide us with the following information:

This issue is a: (mark with an x)

Issue description

In West Europe region I have failed to create Container Apps Environment with virtual network. I followed documentation provided here. Tried both with Azure CLI and Azure Powershell.

Steps to reproduce

  1. Copy paste all commands from documentation until New-AzContainerAppManagedEnv (including it) into powershell script.
  2. Run script.

Expected behavior Successfully create Container Apps Environment with connection to subnet

Actual behavior Error message is display: Message: Fail to create managed environment because provided subnet Id is invalid

Screenshots
image

Additional context

The issue occurred when using Azure Portal, Azure CLI and Azure Powershell.

Additionally I paste my powershell script:

$LOCATION='west europe'
$SubnetArgs = @{
    Name = $SUBNET_NAME
    AddressPrefix = '10.0.0.0/23'
}
$subnet = New-AzVirtualNetworkSubnetConfig @SubnetArgs

$VnetArgs = @{
    Name = $VNET_NAME
    Location = $LOCATION
    ResourceGroupName = $RESOURCE_GROUP
    AddressPrefix = '10.0.0.0/16'
    Subnet = $subnet 
}
$vnet = New-AzVirtualNetwork @VnetArgs
$InfrastructureSubnet=(Get-AzVirtualNetworkSubnetConfig -Name $SubnetArgs.Name -VirtualNetwork $vnet).id

$WorkspaceArgs = @{
    Name = 'myworkspace'
    ResourceGroupName = $RESOURCE_GROUP
    Location = $LOCATION
    PublicNetworkAccessForIngestion = 'Enabled'
    PublicNetworkAccessForQuery = 'Enabled'
}
New-AzOperationalInsightsWorkspace @WorkspaceArgs
$WorkspaceId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $RESOURCE_GROUP -Name $WorkspaceArgs.Name).CustomerId
$WorkspaceSharedKey = (Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName $RESOURCE_GROUP -Name $WorkspaceArgs.Name).PrimarySharedKey

$EnvArgs = @{
    EnvName = $CONTAINERAPPS_ENVIRONMENT
    ResourceGroupName = $RESOURCE_GROUP
    Location = $LOCATION
    AppLogConfigurationDestination = 'log-analytics'
    LogAnalyticConfigurationCustomerId = $WorkspaceId
    LogAnalyticConfigurationSharedKey = $WorkspaceSharedKey
    VnetConfigurationInfrastructureSubnetId = $InfrastructureSubnet
    VnetConfigurationInternal = $true
}
New-AzContainerAppManagedEnv @EnvArgs