Azure Key Vault and Power Automate

If you are storing secrets as plain text in Power Automate flows or environment variables, you can integrate Azure KeyVault in Power Automate to retrieve those credentials directly from Azure Key Vault.

If at any point you run into issues, you can reference Microsoft’s documentation here: Use Azure Key Vault secrets (preview)


Before getting started, we need to knock out some prerequisites in Azure.

Register a resource provider

We need to register Microsoft.PowerPlatform resource provider.

  1. Go to your Azure Portal
  2. Once in the portal, go to Subscriptions
  3. Select the subscription your Azure Key Vault will be in.
  4. Now, select the Resource Providers blade under Settings
Azure Subscription
  1. Search for Microsoft.PowerPlatform in the filter search bar
  2. Select Microsoft.PowerPlatform and select Register
Azure Subscription Resource Provider Blade
  1. This will take a few minutes. Once registered, it should have a green check mark and show as registered.

Configure Azure Key Vault

Now that we have our Power Platform Resource Provider registered, we need to configure Azure Key Vault to allow Dataverse to access the resource.

  1. Go to your Azure Key Vault resource. (My key vault is named Power-Platform)
  2. Select the Access policies blade on the left
  3. Select Add Access Policy
Azure Key Vault Access Policies
  1. The Add access policy window will appear. Select None Selected on the Select Principal* line highlighted in red.
Add access policy
  1. The Principal blade will appear from the right. Search for Dataverse. Select the principal that says Dataverse. The principal ID is 00000007-0000-0000-c000-000000000000
  2. Once selected, click on Select at the bottom.
Search for Principal
  1. Next, select the Secret Permissions drop-down and check Get.
Add access policy
  1. Click Add.
  2. This will bring you back to the main Access policies window. Select Save at the top to commit the changes.
Access policies blade

Configure Environment Variable in Power Automate

Now that we have Azure Key Vault configured, we can set up environment variables inside a solution to retrieve secrets.

Note: A user who creates a Secret Environment Variable needs at least read permissions on the Azure Key Vault resource, or they will receive the following error when attempting to save it.

This variable didn’t save properly. User is not authorized to read secrets from ‘Azure Key Vault path’.

More information can be found here: Create a new environment variable for the Key Vault secret

  1. Go to a Solution that you’re developing in.
  2. In your Solution, create a new Environment Variable. Go to New > More > Environment Variable
Solution in Power Automate
  1. Enter a Display Name for your environment variable
  2. For the Data Type, choose Secret
  3. For Secret Store, choose Azure Key Vault
  4. Next, you can either choose to do a New Azure Key Vault Reference under the Current or Default value. I will use the Default for my example.
  5. Fill in the following fields. You’ll need to reference Azure Key Vault.
    • Azure Subscription Id: This is the subscription your Key Vault is in. You can find it on the Key Vault Overview blade.
    • Resource Group Name: The resource group your Key Vault is in.
    • Azure Key Vault Name: The name of your Key Vault.
    • Secret Name: The display name of your secret in Key Vault.
Configuring Azure Key Vault inside Environment Variable
  1. Select Save
  2. Open the environment variable and copy the Name value. We will need this later.
Name of Environment Variable

If you run into any errors while saving the environment variable about Microsoft.PowerPlatform resource provider, you might wait 10-15 minutes before you try to save again.

Using Secret Environment Variables in Power Automate

Now that we have Azure configured and our environment variable configured, we can use it in our flows within our solution.

For this example, I’ll demonstrate how you can retrieve the secret utilizing the environment variable.

  1. Create a new manually-triggered instant flow.
  2. Select New Step and select Microsoft Dataverse from the actions.
  3. Select Perform an unbound action
Dataverse actions
  1. Once the Perform an unbound action loads, select the action name RetrieveEnvironmentVariableSecretValue
  1. In the EvironmentVariableName field, paste in the Name of the Environment Variable we created earlier. Example: msauto_PowerPlatform_GraphAPI
  1. Select ... > Settings on the top-right corner of the Perform an unbound action, action.
  2. Enable Secure Outputs. This will scrub the secret so it’s not in plain text in the flow run history.
Enable Secure Outputs
  1. Select Save. Now, test your flow.

If successful, you’ll get your secret from Azure Key Vault as shown below. You can use this when making various REST API calls with the HTTP connector such as Microsoft Graph.

Scrubbed Outputs

Want to do more with Azure Key Vault and Power Automate?

If you want to get a better idea of how you can use this in your flows, check out my blog post on using Microsoft Graph with the HTTP connector in Power Automate. You can combine what you learned on this post to securely pull the secret instead of storing it in plain text inside an environment variable.

Jordan Bardwell

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed