A C# background service runs on an Azure Virtual Machine that is configured with a user-assigned managed identity. The service must decrypt sensitive application data using an asymmetric key named `app-decrypt-key` stored in an Azure Key Vault named `contoso-vault`. The Key Vault has Azure role-based access control (Azure RBAC) enabled as its authorization model. You need to grant the minimum necessary permissions to the managed identity and implement the decryption logic in the service's C# code using the Azure SDK for .NET. Which two actions should you perform? (Choose two.)
- Assign the Key Vault Crypto User role to the user-assigned managed identity for the contoso-vault scope.Cevap
- In the C# application code, instantiate a CryptographyClient using the key URI and call its DecryptAsync method.Cevap
- CAssign the Key Vault Crypto User role to the virtual machine's system-assigned managed identity, while configuring the application's DefaultAzureCredential to use the user-assigned managed identity.
- DIn the C# application code, instantiate a KeyClient using the Key Vault endpoint and call its DecryptAsync method.
Cevap
Assign the Key Vault Crypto User role to the user-assigned managed identity for the contoso-vault scope, and in the C# application code, instantiate a CryptographyClient using the key URI and call its DecryptAsync method.
To decrypt data using a Key Vault key under the Azure RBAC model, you must assign a role that grants the data plane permission for cryptographic decryption (such as Key Vault Crypto User) to the identity used by the application (the user-assigned managed identity). In the Azure SDK for .NET, cryptographic operations must be executed using the CryptographyClient class rather than the KeyClient class, which is only used for management tasks.
Adım Adım Çözüm
Anahtar Kavram
Azure Key Vault key cryptography operations and RBAC role assignment using the Azure SDK for .NET.