当我试图从NSG中移除子网时,我遇到了一个问题,因为一个自动过程会破坏资源组中的一些组件。
当我尝试运行这个命令时,我没有问题要删除一个子网的NSG关联。
- name: Dissociate NSG from subnet
environment:
AZURE_CONFIG_DIR: ./.azure
shell: az network vnet subnet update -g Networks -n '{{ subnetName }}' --vnet-name '{{ vnetName }}' --network-security-group "" --subscription '{{ subscription }}'
ignore_errors: yes问题是当我在NSG中有两个或更多的子网(针对不同的组件)时。
如果我在Azure上的bash中运行这个命令,我会得到以下错误:
az network vnet subnet update: error: argument --network-security-group: expected one argument
usage: az network vnet subnet update [-h] [--verbose] [--debug]
[--output {json,jsonc,table,tsv,yaml,none}]我试图了解如何才能不关联NSG中包含的所有子网,而不必为每个子网创建几个块。
发布于 2019-12-30 14:23:34
你可以这样做:
az network nsg show -n nsg_name -g rg_name --query 'subnets[].id' -o tsv要找出NSG所连接的所有子网,然后您可以使用这些子网从这些子网中删除NSG。
az network vnet subnet update --ids [] (resource IDs space-delimited) --network-security-group ""或者你可以一个一个地迭代它们:
az network nsg show -n nsg_name -g rg_name --query 'subnets[].id' -o tsv |
xargs -L 1 az network vnet subnet update --network-security-group "" --ids https://stackoverflow.com/questions/59532168
复制相似问题