Search code examples
azurednsazure-cliazure-virtual-network

az cil vnet --dns-servers


I have a problem with using --dns-servers flag in az cli. When I try to update more than one DNS server it gets broken

az network vnet update \
    --name $VNET_name \
    --subscription $SUBSCRIPTION \
    --resource-group $RGRP_name \
    --dns-servers "${LOCATION[3]} ${LOCATION[4]}"

the output:

IP address is not valid '0.0.0.1 0.0.0.2'

The MS documentation says:

--dns-servers
        Space-separated list of DNS server IP addresses.

Solution

  • ok, figured it out somehow. if you use those vars stright away without closing them withing quotation marks it all works

    . ./location_arrays
    declare -n LOCATION='EM21'
    

    ...

    az network vnet create \
        --name $VNET_name \
        --subscription $SUBSCRIPTION \
        --resource-group $RGRP_name \
        --location ${LOCATION[2]} \
        --dns-servers ${LOCATION[-2]} ${LOCATION[-1]}