Search code examples
azureazure-cliazure-cloud-servicesazure-virtual-network

Azure - cannot get "Network Profile"


my Admin in Azure with full permissions runs the command to retrieve the network profile ID with deployed Virtual Network and Subnet which we are using but the command always returns the empty response:

az network profile list --resource-group myResourceGroup \
  --query [0].id --output tsv

It has permissions, resourceGroup value is correct what should be the case? Why it gets empty response? It is really essential for us to retrieve this value.

The output should contain value in this format:

/subscriptions/<Subscription ID>/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkProfiles/aci-network-profile-aci-vnet-aci-subnet

Thank you


Solution

  • You could verify if you have deployed ACI in that VNet instead of only a standard VNet. When use az network profile, Currently, only Azure Container Instances are supported.

    When you first use the az container create command to deploy a container group to a subnet (and thus a virtual network), Azure creates a network profile for you. You can then use that network profile for future deployments to the subnet.

    For example, if you create a container group in a new VNet or an existing VNet referring to this.

    az container create \
      --name appcontainer \
      --resource-group myResourceGroup \
      --image mcr.microsoft.com/azuredocs/aci-helloworld \
      --vnet aci-vnet \
      --vnet-address-prefix 10.0.0.0/16 \
      --subnet aci-subnet \
      --subnet-address-prefix 10.0.0.0/24
    

    Then you will list the network profile in that resource group.

    enter image description here

    Update

    If you want to deploy a container in an existing VNet, you can deploy it like this with --vnet NAME --subnet NAME | --vnet ID --subnet NAME | --subnet ID:

    az container create --name appcontainer --resource-group nancylab --image mcr.microsoft.com/azuredocs/aci-helloworld --vnet aci-vnet --subnet subnet1
    

    enter image description here