For scripts it's better to use the following:
export KUBERNETES_SERVICE_CIDR="$(az aks show --resource-group $RG --name $AKSNAME --query networkProfile.serviceCidr -o tsv)"