Azure key vault

Azure key vault documentation is here

Here is the learning path for azure key vault

These learning paths are usually good

Azure Key Vault's API uses Azure Active Directory to authenticate users and applications

Three actions: Get, Set, List

Permissions to these actions are across the vault, no smaller granularity

For apps, often only Get permissions are required.

Good practice is to create a separate vault for each deployment environment of each of your applications, such as development, test, and production

If you use the same names for secrets across different environments for an application, the only environment-specific configuration that has to change in your app is the vault URL.

Vault names must be globally unique, so you'll need to pick a unique name. Vault names must be 3-24 characters long and contain only alphanumeric characters and dashes

Apps and users authenticate to Key Vault using an Azure Active Directory authentication token

When you enable managed identity on your web app, Azure activates a separate token-granting REST service specifically for use by your app. Your app will request tokens from this service instead of directly from Azure Active Directory. Your app needs to use a secret to access this service, but that secret is injected into your app's environment variables by App Service when it starts up. You don't need to manage or store this secret value anywhere, and nothing outside of your app can access this secret or the managed identity token service endpoint.

1. When you enable managed identity on your web app, Azure activates a separate token-granting REST service specifically for use by your app.

2. Your app will request tokens from this service instead of directly from Azure Active Directory.

3. Your app needs to use a secret to access this service, but that secret is injected into your app's environment variables by App Service when it starts up.

4. You don't need to manage or store this secret value anywhere, and nothing outside of your app can access this secret or the managed identity token service endpoint.

Managed identity for data factory is documented here

Documentation: Provide Key Vault authentication with a managed identity

I am hoping to find here to learn about setting a policy for the vault where it can allow a managed identity principal (like a data factory) to read from the vault

The policy screen is very confusing on its own. Hoping this document will shed light

1. See section called Grant your app access to Key Vault

2. Meaningful drop downs are a) Select permissions (get, list) b) select prinicipal

3. Select principal will open a search panel to the right: I have entered the beginning string of the data factory resource name. It picked it up

Options for Access policies screen in azure key vault

Search for: Options for Access policies screen in azure key vault

Security recommendations for azure key vault

what is the difference between keys and secrets in Azure key vault?

Search for: what is the difference between keys and secrets in Azure key vault?

1. Create a key vault

2. Locate the data factory name that is going to be accessing the key vault in order invoke a function.

3. Add a policy to the key vault using: a) Select permissions (get, list) b) select prinicipal (you will use the data factory name here to locate the data factory). make sure you click the "save" button.

4. Locate your pipeline where you have a function activity

5. Function activity points to a linked service that connects you to the function app

6. it is in this linked service you need to spec a function key. Instead you point to the key vault

7. Key vault also needs a linked service (no surprises here in setting this up as you don't need to provide any access control passwords)

8. Meanwhile, you have to locate the function key by going to the function app and locating your function and locating the "manage" option under that function and copying the necessary function or master keys. Your app must be running to locate these keys. (I am yet to fully understand the difference between master and host keys)

9. then go to the key vault and and put that key as a "secret" with a name

10. Now come back to the function app linked service and specify this secret as the key to the vault.

11. the key vault does not prompt you to the existing secret names. would have been nice if it did. so you have to remember what name you have given it to the secret and type that in

12. Then save and publish it and use debug to see if your app is called

13. It did in my case


{
    "name": "Satya_fapp_01_getDirectoryName",
    "properties": {
        "description": "Satya_fapp_01_getDirectoryName",
        "annotations": [
            "Satya",
            "usage_individual"
        ],
        "type": "AzureFunction",
        "typeProperties": {
            "functionAppUrl": "https://fapp-01-satya.azurewebsites.net",

            "functionKey": {
                "type": "AzureKeyVaultSecret",
                "store": {
                    "referenceName": "ls_test_AzureKeyVault",
                    "type": "LinkedServiceReference"
                },
                "secretName": "satya-fapp-01-mster-key"
            }

        }
    },
    "type": "Microsoft.DataFactory/factories/linkedservices"
}

{
    "name": "pl_test_af_keys_in_vault",
    "properties": {
        "description": "Call an azure function. 
              Get a directory name. 
              Test that the keys can be taken from the vault",
        "activities": [
            {
                "name": "Azure Function1",
                "type": "AzureFunctionActivity",
                "dependsOn": [],
                "policy": {
                    "timeout": "7.00:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false,
                    "secureInput": false
                },
                "userProperties": [],
                "typeProperties": {
                    "functionName": "SatyaFapp01HttpTrigger",
                    "method": "POST",
                    "body": {
                        "value": "{\n   \"name\": \"satya\"\n}",
                        "type": "Expression"
                    }
                },
                "linkedServiceName": {
                    "referenceName": "Satya_fapp_01_getDirectoryName",
                    "type": "LinkedServiceReference"
                }
            }
        ],
        "annotations": [
            "satya"
        ]
    },
    "type": "Microsoft.DataFactory/factories/pipelines"
}