Skip to content

Instantly share code, notes, and snippets.

@dbafromthecold
Created October 6, 2018 13:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbafromthecold/21d3939a7cc23cbe2e6a1b05e30d2689 to your computer and use it in GitHub Desktop.
Save dbafromthecold/21d3939a7cc23cbe2e6a1b05e30d2689 to your computer and use it in GitHub Desktop.
delete_aci-virtualnetwork
# https://docs.microsoft.com/en-us/azure/container-instances/container-instances-vnet
# log into Azure
az login
# Set variables for resource group, virtual network, and subnet
RES_GROUP=containers1
VNET=vnet1
SUBNET=subnet1
# Get network profile ID
NETWORK_PROFILE_ID=$(az network profile list --resource-group $RES_GROUP --query [0].id --output tsv)
# Delete the network profile
az network profile delete --id $NETWORK_PROFILE_ID -y
# Get the service association link (SAL) ID
SAL_ID=$(az network vnet subnet show --resource-group $RES_GROUP --vnet-name $VNET \
--name $SUBNET --query id --output tsv)/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default
# Delete the default SAL ID for the subnet
az resource delete --ids $SAL_ID --api-version 2018-07-01
# Delete the subnet delegation to Azure Container Instances
az network vnet subnet update --resource-group $RES_GROUP --vnet-name $VNET --name $SUBNET --remove delegations 0
# Delete the subnet
az network vnet subnet delete --resource-group $RES_GROUP --vnet-name $VNET --name $SUBNET
# Delete virtual network
az network vnet delete --resource-group $RES_GROUP --name $VNET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment