0

I'm trying to update Azure AD App by executing the following command

Now first this is the result of echo of appId

enter image description here

now when i try to execute the update command:

enter image description here

now if i try the same command with the value inline it works as below:

enter image description here

I'm not sure what is wrong !, and why using a variable does not work but using inline value works, this is part of a long script so its important for me to utilize variables.

Any one faced this before ?

Stacker
  • 8,157
  • 18
  • 73
  • 135
  • 1
    Could you try with enclosing in double quotes? --id "#appId" – Sajeetharan Apr 17 '21 at 19:12
  • I tried that, and i get the same result! – Stacker Apr 17 '21 at 19:15
  • Damn, well I guess all is lost gg – segFault Apr 17 '21 at 19:28
  • 1
    Where's `$appId` from? The second screenshot makes me think there's a carriage return in there. What do you see for `declare -p appId`? – Benjamin W. Apr 17 '21 at 19:34
  • "eclare -- appId="33991168-xxxx-4799-974b-f14d932f9e61 dont mind the number changing i keep trying so it keeps changing but same behavior... – Stacker Apr 17 '21 at 19:42
  • $appId is the result of a previous command to create the application – Stacker Apr 17 '21 at 19:45
  • 1
    You have a carriage return in that variable, look at how it's `"eclare` instead of `declare` – that's the missing closing double quote. See [How to remove carriage return from a variable in shell script](https://stackoverflow.com/q/15520339/3266847) – Benjamin W. Apr 17 '21 at 19:45
  • 1
    It becomes even more clear with `printf '%q\n' "$appId"` – Benjamin W. Apr 17 '21 at 19:46
  • this is the previous command: appId=$(az ad app create --display-name "${clusterName}-aad-server" --identifier-uris "https://${clusterName}-aad-server" --query appId -o tsv) – Stacker Apr 17 '21 at 19:47

1 Answers1

0

Thanks to @BenJamin W reference, I had to change the command to:

az ad app update --id ${appId//$'\r'} --set groupMembershipClaims=All

This removed the $ and the newline at the end.

Stacker
  • 8,157
  • 18
  • 73
  • 135