'Trying to create secret in Azure Key Vault using Azure Functions

I am trying to create a secret whenever a text file is uploaded to blob storage but I am getting the following error using the az command:

[Warning] The Function app may be missing a module containing the 'az' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7.

This is my function

param([byte[]] $InputBlob, $TriggerMetadata)
Import-Module az
Set-AzureKeyVaultSecret -VaultName myakv -Name Mysecret -SecretValue abcde

And this is my requirements.psd1

@{
Az = '7.*'
}

Appreciate if anyone could give me some advice. Thank you!



Solution 1:[1]

  • As functions are serverless code, in general, we don't have the Key vault we need to integrate it manually by adding a piece of code. Below is the sample code on integrating function app with Kay Vault enter image description here

  • As suggested by Anand-Sowmithiran You can use Set-AzKeyVaultSecret for creating key vault secret in azure functions.

  • Here is the document for Integrating Key Vault in Azure functions. You can refer to this for further information.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SaiSakethGuduru-MT