There seems to be a bug creating service principal (running on Git Bash) -
If I run az ad sp create-for-rbac --name $ACR_NAME-pull --scopes $(az acr show --name $ACR_NAME --query id --output tsv) --role acrpull --query password --output tsv
I get an error in requests:
msrest.exceptions.ClientRequestError: Error occurred in request., InvalidSchema: No connection adapters were found for <path>
For some reason it seems to be concatenating a Git folder path:
C:/Users/<username>/AppData/Local/Programs/Git
with the result of $(az acr show --name $ACR_NAME --query id --output tsv) which looks like:
/subscriptions/<id>/resourceGroups/<resource group name>/providers/Microsoft.ContainerRegistry/registries/<registry name>/providers/Microsoft.Authorization/roleDefinitions?$filter=roleName%20eq%20%27acrpull%27&api-version=2018-01-01-preview
resulting in it trying to make an HTTP request to a file location on my C: drive, which obviously doesn't work
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
This seems to be a problem running on Git Bash - with some modification I managed to run the same command on a Command Prompt and it worked
Thanks for the feedback! We are currently investigating and will update you shortly.
@MarkBird generally the commands are written to run in the Azure Cloud shell which I tested and did not get the same error. Running on a on-prem bash environment sometimes does not work exactly as copied. We have had this kind of issue on a few docs. Unfortunately it is hard to write commands and scripts that will work for everyone specific environment.
I will close this out as the commands do appear to work as written in the Cloud Shell environment
CC @dlepow
It would be very helpful to people in the future if you could sort this out. Just saying it's ok cos it wroks in the cloud shell is just very annoying to those whove wasted an hour or two using Bash before finding this. issue.
Yes, to state that its hard to write scripts to work everywhere is a bit like state that its enough to write software which works only on my local computer 😂😂
I also receive this same error that appears to be based on the same bug when I run the following command with the Azure CLI from a git bash prompt:
az role assignment create --assignee $spID2 --role 'Contributor' --scope /subscriptions/my-subscription-id/resourcegroups/RG2/providers/Microsoft.Network/networkSecurityGroups/my-nsg-name
Here is the error:
ClientError: Error occurred in request., InvalidSchema: No connection adapters were found for 'C:/Program Files/Git/subscriptions/my-subscription-id/resourcegroups/RG2/providers/Microsoft.Network/networkSecurityGroups/my-nsg-name/providers/Microsoft.Authorization/roleDefinitions?$filter=roleName%20eq%20%27Contributor%27&api-version=2018-01-01-preview'
I guess I'll need to switch over to Powershell for this task.
This Bug is was never solved and should be reopened again. I create a new issue.
Thank you for creating that issue in the right repo @mruepp ! In case anyone hasn't seen it, here is the link: https://github.com/Azure/azure-cli/issues/16317
Most helpful comment
It would be very helpful to people in the future if you could sort this out. Just saying it's ok cos it wroks in the cloud shell is just very annoying to those whove wasted an hour or two using Bash before finding this. issue.