Can Azure Key Vault be used with Functions to store the connection string for queue triggers?

后端 未结 2 1427
醉酒成梦
醉酒成梦 2021-01-22 00:46

I was able to use the Key Vault inside a function app as described here but when I tried to use the Key Vault to hold the connection string of a function with a queue trigger I

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-22 01:01

    I'm trying to test first in Visual Studio.

    For now using Azure Key Vault references with Azure Functions does not support to work on local, as confirmed by Azure Functions team. If you still want to test on local, you could implemented an incomplete local workaround like this issue.

    I test on portal and it works well. You could refer to the following steps as below:

    1.In VS Function.cs, then publish to azure:

     public static void Run([QueueTrigger("queue", Connection = "AzureWebJobsStorage")]string myQueueItem, TraceWriter log)
     {
         log.Info($"C# Queue trigger function processed: {myQueueItem}");
         string connectionString = System.Environment.GetEnvironmentVariable("AzureWebJobsStorage");
         log.Info($"The connection string is {connectionString}");
     }
    

    2.Set AzureWebJobsStorage on Appsettings setting on portal.

    3.Then it will work fine.

提交回复
热议问题