Azure / Azure/azure-cli

Assigning Access Policy to Service Principal using Object ID is wrong

Open
#18,689 1 comment 0 reactions 1 assignee Claimed by @evelyn-ys View on GitHub
act-identity-squad Documentation feature-request KeyVault
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

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

**Describe the bug**
I've been following the [official docs](https://docs.microsoft.com/en-us/azure/key-vault/general/assign-access-policy-cli) to assign an Access Policy to a Service Principal in order to be able to authenticate locally against Key Vault via the Azure.Identity library.

**To Reproduce**
Create SP using the CLI
Add Reader Role and scope only to KV
Use CLI to assing the SP an Access Policy in Key Vault using the Object ID of the Service Principal
Running the application and trying to authenticate against AAD throws an access error

**Expected behavior**
When assigning a Key Vault Access Policy to a Service Principal, the docs instruct that we need to use the Object ID. This works and assigns a policy. However, when attempting to use that account to access the KV, it fails. Instead, we need to use the App Id of the Service Principal in order to assign the policy. The Azure CLI should throw an error when using the wrong ID. In addition, our docs need to be updated accordingly!

**Environment summary**
latest version of Azure CLI on Windows 11/Windows 10

**Additional context**
Blog post with more details and source code [here](https://dev.to/425show/secure-python-console-apps-with-azure-ad-54fo)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.