尝试将自定义角色 "Secret Reader" 分配给 Azure Key Vault 的对象 ID 时出错

Error while trying to assign a custom role "Secret Reader" to an object ID for an Azure Key Vault

谁能告诉我为什么在尝试 运行 此命令并将自定义角色“Secret Reader”分配给来宾帐户对象 ID 时出现此错误:

az role assignment create --role "Secret Reader" --assignee-object-id "12526c57-c91b-405b-9068-2b582b23e83a" --scope "/subscriptions/Not-putting this-here/resourceGroups/pallabdev/providers/Microsoft.KeyVault/vaults/testhalvault"

我得到的错误是:

request failed: Error occurred in request., InvalidSchema: No connection adapters were found for 'C:/Program Files/Git/subscriptions/Not-Putting-This-Here/resourceGroups/pallabdev/providers/Microsoft.KeyVault/vaults/testhalvault/providers/Microsoft.Authorization/roleDefinitions?$filter=roleName%20eq%20%27Secret%20Reader%27&api-version=2018-01-01-preview'

从错误消息来看,我想你 运行 Git Bash of Windows 中的命令,我也可以在我这边重现这个,这是造成的通过 Auto-translation of Resource IDs in Git Bash, similar issue here.

要解决此问题,只需设置环境变量MSYS_NO_PATHCONV=1或在您运行命令时临时设置它。

$ MSYS_NO_PATHCONV=1 az role assignment create --role "Secret Reader" --assignee-object-id "12526c57-c91b-405b-9068-2b582b23e83a" --scope "/subscriptions/Not-putting this-here/resourceGroups/pallabdev/providers/Microsoft.KeyVault/vaults/testhalvault"