Jump to content

Switching to Key Vault Secrets usage for Function App based Microsoft Sentinel Data Connectors


Recommended Posts

Guest PrateekTaneja
Posted

Overview

 

 

Microsoft Sentinel’s REST – API based data connectors a lot of times use secrets and keys that customers would prefer to keep secured in a vault from where they can effectively manage (retrieve, update, delete, manage access, etc.) these secrets and keys. In this article, we’ll talk about securing API secrets and keys using an Azure Key Vault.

 

Content Hub solution when deployed may not necessarily deploy the Azure Key Vault resources as a part of the solution deployment to account for varied usage of Azure Key Vaults. However, Azure Function apps can use keys stored in AKV using AKV references without any changes in the Azure Function App code.

 

Integrating with AKV is a three – step process:

 

  1. Ensure the Function App & Key Vault have the right permissions
  2. Create the secrets in the Key Vault
  3. Add Key Vault References in the Function App

 

Let’s talk about each of these in more detail.

 

 

 

Ensure the Function App & Key Vault have the right permissions

 

 

You could choose to create a new or use an existing Key Vault to store and manage your API keys and/secrets. To create a new Azure Key Vault, follow the steps documented on the official documentation.

 

 

 

Manage Permissions

 

 

Once created, you need to ensure that sufficient permissions have been assigned for the Function App to read the secrets from the Key Vault. Your Function App must have managed identity enabled. This could either be system-generated or user-generated. For the purpose of this article, we’ll continue to use a system generated managed identity.

 

To enable system assigned managed – identity on the Function App,

 

  1. Navigate to the Function App in the Azure Portal and click on Identity.
  2. Still under the System assigned tab, switch the Status to On if its currently set to Off. Click Save.

 

mediumvv2px400.png.a15f71dc3057948e1e0b3939fc96d42f.png

 

3. On saving, it should auto generate an Object with an Object ID. Copy the Object ID to keep it handy, you’ll need it in some time.

 

mediumvv2px400.png.f3e8dca1ccf705d5a29cd1179b3302f0.png

 

 

 

To provide access to the Function App’s managed – identity to read secrets from the Azure Key Vault,

 

  1. Navigate to the Key Vault on the Azure Portal.
  2. Click on Access Control (IAM).
  3. Next, click on Add and then on Add role assignment.

 

mediumvv2px400.png.4c0322367d0449f3394cc58828a6f770.png

 

4. Select the
Key Vault Secrets User
role from the list of roles and then click
Next
.

 

5. On the Members tab, for Assign access to, select
Managed identity
and then click on ‘
+ Select members
’.

 

On the configuration pane that opens on the right, make the following selections:

 

  • Subscription
    – The subscription in which your Function App resides.


  • Managed identity
    – Function App


  • Select
    – From the dropdown, select the name of the Function App.


 

When the selections are complete, click on
Select
.

 

6. The Members should now have the name of the Azure Function app along with the Object ID of the Managed identity populated.

 

mediumvv2px400.png.070ac54b84d0deeaff0bb135d7131eab.png

 

 

 

7. Optionally, add a
Description
.

 

8. Click on
Review + assign
.

 

 

Create the Secrets in the Key Vault

 

 

You can manually create Secrets in the Key Vault.

 

  1. On the Azure Portal, navigate to Azure Key vault and select the Key vault that was created earlier.
  2. On the left-hand pane, click on Secrets.
  3. Next, click on + Generate/Import. mediumvv2px400.png.c5c96b489dd6e1bafef5a5a651144706.png
  4. Make the following selections on the Create a secret page:

  1. Upload options: Manual


  2. Name: <Name/Identifier of the Secret>


  3. Secret value: <Value of the Secret>. (This will be the actual string that the Function App will need to connect to the API)


  4. Enabled: Yes


 

The other value can be left default.

 

mediumvv2px400.png.59c73650d93205fe708aec570dc4d816.png

 

5. Click
Create
.

 

6. Now, to extract the SecretUri,

 

a. Select the Secret that was created in the previous step

 

b. Click on the Current Version

 

mediumvv2px400.png.8ddb4551781e19b0bc5f6e0423ad4b59.png

 

c. Copy the
Secret Identifier
.

 

 

 

mediumvv2px400.png.3b62dde50908a233d6e141b825a8d8f9.png

 

 

Add Key Vault References in the Function App

 

 

Azure Function Apps will now need to be re-configured to extract the secrets from the Key Vault instead of using the plain – text strings. To do that,

 

  1. On the Azure Portal, navigate to Function Apps and select your Function App.
  2. On the left-hand pane, click on Configuration.
  3. Click on Advanced Edit and you’ll notice a configuration pane open on the right with all the configuration parameters in json format.
  4. Look for the name of the configuration setting you wish to edit and for the setting, edit the value as:

 

.KeyVault(SecretUri=https://<key-vault-name>.vault.azure.net/secrets/<secret-name>/<secret-version>)

 

Note: The value of the SecretUri was the secret identifier copied from the Secret created in the previous section.

 

5. Click
Ok
.

 

6. Back on the Function App settings, click
Save
and then
Continue
. This will apply the changes to the Function App.

 

7. Now, back on the Function App settings, click on
Refresh
and click
Continue
.

 

You will now also notice that the Source in the Configuration Setting that was just modified changes to
Key vault Reference
from App Service.

 

mediumvv2px400.png.d457afd4596b0d4a0a5004dbb3da5b18.png

 

 

 

The Function App is now configured to extract the Secret values from Key Vaults instead of reading plain-text values from the Configuration Settings.

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...