azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az afd custom-domain create with azure-dns-zone fails

Open utillity opened this issue 1 year ago • 3 comments

Describe the bug

When I try to pass in the azure-dns-zone, the cli seems to think it's a path and make an absolute path out of it, then it complains that it's not a valid ID

Related command

az afd custom-domain create

Errors

The output including the error message

Using DNS Zone-Id: /subscriptions/xxxxxxx/resourceGroups/xxxxx/providers/Microsoft.Network/dnszones/dev.xxxxx.eco
(LinkedInvalidPropertyId) Property id 'C:/Program Files/Git/subscriptions/xxxxx/resourceGroups/xxxxxx/providers/Microsoft.Network/dnszones/dev.xxxxx.eco' at path 'properties.azureDnsZone.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.
Code: LinkedInvalidPropertyId
Message: Property id 'C:/Program Files/Git/subscriptions/xxxxx/resourceGroups/cxxxxxx/providers/Mi
crosoft.Network/dnszones/dev.xxxxx.eco' at path 'properties.azureDnsZone.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.

Issue script & Debug output

My bash script (relevant part of it)

  local zoneId=$(az network dns zone list -g "$commonResgrp" --query [0].id)
  local zoneId=${zoneId:1:-1}
  echo "Using DNS Zone-Id: $zoneId"
  # https://learn.microsoft.com/en-us/cli/azure/afd/custom-domain?view=azure-cli-latest#az-afd-custom-domain-create
  az afd custom-domain create --resource-group "$resgrp" --profile-name "$profName" \
    --host-name "$customDomain" --custom-domain-name "$afdUrl" \
    --azure-dns-zone "$zoneId" \
    --minimum-tls-version TLS12 --certificate-type AzureFirstPartyManagedCertificate

Expected behavior

It should accept the supplied zoneId /subscriptions/xxxxxxx/resourceGroups/xxxxx/providers/Microsoft.Network/dnszones/dev.xxxxx.eco

Environment Summary

$ az --version
azure-cli                         2.65.0

core                              2.65.0
telemetry                          1.1.0

Dependencies:
msal                              1.31.0
azure-mgmt-resource               23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\xxx\.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb  6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

Additional context

No response

utillity avatar Oct 18 '24 18:10 utillity

Thank you for opening this issue, we will look into it.

yonzhan avatar Oct 18 '24 18:10 yonzhan

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dnssuppgithub.

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @cdnfdsuppgithub, @t-bzhan, @gxue, @TracyYaoYao.

I tried

az network dns zone list -g "$rg" --query [0].id

and get

"/subscriptions/$subid/resourceGroups/$rg/providers/Microsoft.Network/dnszones/$zone"

If you use local zoneId=${zoneId:1:-1}, the fisrt character /will not be extracted, which not match the conditions that "start with '/subscriptions/{subscriptionId}'".

Ptnan7 avatar Dec 12 '24 03:12 Ptnan7

I tried

az network dns zone list -g "$rg" --query [0].id

and get

"/subscriptions/$subid/resourceGroups/$rg/providers/Microsoft.Network/dnszones/$zone"

If you use local zoneId=${zoneId:1:-1}, the fisrt character /will not be extracted, which not match the conditions that "start with '/subscriptions/{subscriptionId}'".

local zoneId=${zoneId:1:-1} is used to remove quotation marks from the string, that is not the reason for the failure.

@utillity , it seems that MinGW/MSYS will mangling the paths from the command: https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line To disable the behavior, you could set

MSYS_NO_PATHCONV=1

t-bzhan avatar Dec 31 '24 06:12 t-bzhan