question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to create service principal with azure cli from git bash shell, no connection adapters were found.

See original GitHub issue

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug When trying to create an azure service principal from git bash or programatically from bash scripts, the task fails with the following error:

Creating a role assignment under the scope of "C:/Program Files/Git/subscriptions/yyy-yyy-xxx-xxx"
Role assignment creation failed.

ClientError: Error occurred in request., InvalidSchema: No connection adapters were found for 'C:/Program Files/Git/subscriptions/yyy-yyy-xxx-xxx
xxx-xxx-yyy-yyy/providers/Microsoft.Authorization/roleDefinitions?$filter=roleName%20eq%20%27Contributor%27&api-version=2018-01-01-preview'

This is a long persistent error and is still not solved. We need to bootstrap environments programatically.

The command involved is:

ARM_CLIENT_SECRET=$(az ad sp create-for-rbac
--name "http://$ARM_PRINCIPAL_NAME"
--role Contributor
--scopes "/subscriptions/$ARM_SUBSCRIPTION_ID"
--query password
--output tsv)

I also tried to change the read write permissions of the C:/Program Files/Git and its subfolders, no change.

Strange is, the sp gets created but incomplete and the command does not return the client secret. Also the role assigment gets created to an unknown identity - see screenshot

To Reproduce Issue the following command:

ARM_CLIENT_SECRET=$(az ad sp create-for-rbac
--name "http://$ARM_PRINCIPAL_NAME"
--role Contributor
--scopes "/subscriptions/$ARM_SUBSCRIPTION_ID"
--query password
--output tsv)

Expected behavior Execute command and return client secret or other variable depending on the query

Environment summary Windows 10 Git Bash

Additional context 2020-12-18 11_14_36-Window

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

33reactions
fengzhou-msftcommented, Jan 28, 2021

You need to set MSYS_NO_PATHCONV=1 to avoid auto-translation of the resource id: https://github.com/Azure/azure-cli/blob/dev/doc/use_cli_with_git_bash.md#auto-translation-of-resource-ids

10reactions
devniel93commented, Feb 8, 2021

Thanks @fengzhou-msft. I had to do something like this SP_PASSWD=$(MSYS_NO_PATHCONV=1 az ad sp create-for-rbac
–name http://$ACR_NAME-pull
–scopes $ACR_REGISTRY_ID
–role acrpull
–query password
–output tsv)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure CI/CD for a Python web app in Azure Container Apps
For more information, see the GitHub issue Unable to create service principal with Azure CLI from git bash shell, no connection adapters were ......
Read more >
How To Easily Create An Azure Service Principal (Step-by-Step)
Type the name of the service principal and then select it. Afterward, click on “Review + assign”. Problems. Unable to create service principal...
Read more >
How to setup Azure CLI for use with Bash shell in Windows
Check first using either Cmd or Powershell, by running e.g. If you have Git installed you will have bash installed as part of...
Read more >
Azure CLI in Git Bash - Stack Overflow
Sometimes commands in windows git bash need .cmd appended. Also, another way of installing the Azure-Cli is through Chocolatey ...
Read more >
Untitled
... group doesn't give proper access #9967 Unable to create service principal with azure cli from git bash shell, no connection adapters were...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found