简体   繁体   中英

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!

  • 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在此处输入图像描述

  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM