Using Azure Key Vault for Securing Azure Function Apps

What is Azure Key Vault?

The Azure Key Vault that is provided by Microsoft is a cloud management service that allows the user to encrypt their sensitive information by using keys that are protected by hardware security modules. Generally, Azure Key Vault is a tool that can be used to secure the keys by storing and certificates. We can use them from the Vault when needed. For securing our information like password, connection string in a secure way we can use Azure Key Vault. A vault is a logical group of secrets.

By the way, anybody with the Azure Subscription can create and use key vaults. It can be implemented and managed by the organization’s administrator to manage the services. Let’s say for an example: An Administrator can create a vault for the organization to store the keys and operational tasks like

  • Creating or importing a key.
  • Revoking or deleting a key.
  • Authorizing the users to access the key vault so that users are managed to use the keys from the vault.
  • Configuring Key usage.
  • Monitoring Keys usage.

An important point I would like to mention is the secret keys can be protected by software or FIPS 140-2 level 2 validated HSMs.

Prerequisites

  • Active Azure Login Subscription.
  • Visual Studio 2017 or Later.

Use of Azure Key Vault

  • The Azure Key Vault helps the organizations/ users to solve the listed problems.
  • Secret Management- The Vault can be used to securely store the tokens, passwords, etc.
  • Certificate Management- The key vault is a service that manages and deploys public and private socket layers (SSL/TLS) certificates and internal connected resources.
  • Key Management- The Key Vault can be used as a management solution in which the vault makes a way of creating and controlling the encryption keys used to encrypt the data.
  • By following the steps below, we can be able to secure Azure Function app with the help of setting the Azure Key Vault.

Step 1

Sign in to the online Microsoft Azure Portal.

Step 2

From the Azure portal menu, or from the Home page, select Create a resource. In the Search box, enter Key Vault. From the results list, choose Key Vault. On the Key Vault section, choose to Create.

Now we need to provide some of the basic requirements for creating the key vaults like

  • Providing a Key vault Name.
  • Select the region for which the key vault to be created.
  • Select the pricing tier to standard and leave the other options to be a default and finally select >> Review + create.

This is image title

This is image title

Step 3

Now we need to select the Access Policy and leave the rest values to be in default and select >> Review + Create.

This is image title

Step 4

Select >> Create for creating an Azure Key Vault and it can take few minutes for setting up and the Azure Key Vault will be created.

This is image title

Step 5

Select >> Secrets from the left side menu and click >> Generate/ Import and copy the secret identifier to the clipboard so that it can be used later.

This is image title

This is image title
 
Step 6

Create a Function App and for creating an Azure Function App you can refer to the following link.

Select the Function App >> and select Identity from the platform features.

This is image title

Step 7

Copy the Object ID using copy board and it can be used later

This is image title

Step 8

Now Select >> Access Policies from the Key Vault and we can see current Access Policies, select >> Add Access Policy and fill the values and select >> Add.

This is image title

This is image title

Step 9

Now switch back again to function app and select >> Configuration in platform features and copy the value to the clipboard so that we can use it later and Click >> Ok.

This is image title

This is image title

After that the application setting will be added

Step 10

Open Visual Studio 2019 or 2017, Click >> New project and select >> Function App

Replace the following application setting value inside of it and publish the code.

This is image title

This is image title

So that we can check in the Azure portal, copy your newly deployed function and after put in URL with a browser.

Summary

In this article, we discussed how to create secure the Azure Function Apps using the Azure Key Vault.

#azure #Key Vault #security #devops

Using Azure Key Vault for Securing Azure Function Apps
2.35 GEEK