I am mangling a url with the following code:
#!/bin/bash
DATAFACTORIES="$(az resource list --resource-group XXXXXXXXXXXXXXXX --resource-type Microsoft.DataFactory/factories --query [*].id -otsv)"
for df in $DATAFACTORIES; do
my_uri=https://management.azure.com$df/?api-version=2018-06-01
TRIGGERS="$(az rest --method GET --uri $my_uri)"
done
The command that is being run is:
az rest --method GET --uri https://management.azure.com/subscriptions/YYYY/resourceGroups/XXXXXXXXXXXXXXXX/providers/Micros/?api-version=2018-06-01s/zzz
when I expect it to be:
az rest --method GET --uri https://management.azure.com/subscriptions/YYYY/resourceGroups/XXXXXXXXXXXXXXXX/providers/Microsoft.DataFactory/factories/zzz?api-version=2018-06-01
CodePudding user response:
It's probably because az
returned result with DOS line endings, try :
my_uri="https://management.azure.com${df%$'\r'}/?api-version=2018-06-01"
${df%$'\r'}
removes \r
from the end of the variable df