Populating environment variables with secret values in AzureML

Viewed 45

I'm setting up an AzureML pipeline which runs a command-line application using CommandStep. The command-line application expects to receive some credentials in the form of environment variables.

At the moment the best solution I can find is to wrap the command-line application in a PythonScriptStep, where the Python script will:

  1. Retrieve the credentials from the AzureML Keyvault as described here;
  2. Set the environment variables; then
  3. Use a subprocess call to run the command-line application.

Is there a simpler way to do this without requiring a Python script? For example, is it possible to configure the AzureML environment to populate environment variables directly from the Keyvault?

1 Answers

To populate environment variables directly from the Keyvault we need to create two things in this procedure.

  1. Create key vault
  2. Create App in App Services

Follow the procedure to populate environment variables directly from Keyvault?

Go to Key Vault

enter image description here

enter image description here

enter image description here

enter image description here

Now got to App service

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Go to Identity tab

enter image description here

enter image description here

Select the ON status and click on SAVE

Now go to key vault and -> Goto Access Policies and click on create

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Now the app services are assigned with key vaults, now we can use the app service to get the environment variables from key vault without any programmatical manner. Including the above steps, we need to decide what are the variables we need to get. Copy the Vault URI: https://learning-key-vault-1234.vault.azure.net/variables/secretkey

Now the app services are assigned with key vaults, now we can use the app service to get the environment variables from key vault without any programmatical manner.

Including the above steps, we need to decide what are the variables we need to get.

Copy the Vault URI: https://learning-key-vault-1234.vault.azure.net/variables/secretkey

enter image description here

enter image description here

This will retrieve the environmental variables required from secret key vault.

Related