How to prevent Azure CLI from creating associated resources in random new resource groups?

Greg Quinn 116 Reputation points
2024-02-04T02:33:21.96+00:00

I am using the Azure CLI to create a Container App Environment, and a virtual network. I followed the instructions here
https://learn.microsoft.com/en-us/azure/container-apps/vnet-custom?tabs=bash%2Cazure-cli&pivots=azure-cli

These are the commands I used...

az network vnet create --resource-group rg-block-trucks --name vnet-block-trucks --location westus2 --address-prefix 10.0.0.0/16

az network vnet subnet create --resource-group rg-block-trucks --vnet-name vnet-block-trucks --name subnet-block-trucks --address-prefixes 10.0.0.0/21

az containerapp env create --name cae-block-trucks --resource-group rg-block-trucks --location westus2 --infrastructure-subnet-resource-id /subscriptions/0baece7a-8562-4d41-b4f9-bd83f016df1f/resourceGroups/rg-block-trucks/providers/Microsoft.Network/virtualNetworks/vnet-block-trucks/subnets/subnet-block-trucks

As you can see, I am specifying a resource group rg-block-trucks, every time, I would assume Azure would create any associated resources in this same resource group?

I also set the default resource group using az configure, so my az config get defaults returns...

[
  {
    "name": "group",
    "source": "C:\\Users\\greg\\.azure\\config",
    "value": "rg-block-trucks"
  },
  {
    "name": "location",
    "source": "C:\\Users\\greg\\.azure\\config",
    "value": "westus2"
  }
]

But Azure creates the following two resources, in this new random group that I never asked for...

Load Balancer - ME_cae-block-trucks_rg-block-trucks_west

Public IP - ME_cae-block-trucks_rg-block-trucks_west

How do I force it to create any associated resources in my rg-block-trucks resource group?

Note : I am unable to move these resources into my resource group. Thanks!

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
229 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 68,426 Reputation points
    2024-02-04T04:15:46.2433333+00:00

    Hi Greg,

    Unfortunately you cannot force it to create the infrastructure managed resources in the same resource group. For workload profiles environment you can customize the name of the infrastructure resource group that gets created if you want, but not put things in same group.

    If you don't need to use your own virtual network then you could use generated one instead and then the separate resource group (and lb/public ip) will not get created.

    Please see article below for more details on networking and managed resources that are created:

    Networking in Azure Container Apps environment

    https://learn.microsoft.com/en-us/azure/container-apps/networking

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful