Vivendi
Vivendi

Reputation: 21007

Send data to Azure Functions using QueueTrigger from a Nuget package

I have been testing my Azure Functions using a QueueTrigger. I tested my queue by using the following code to put something on the queue.

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=storage.....etc");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("mysecondqueue");
queue.CreateIfNotExists();
queue.AddMessage(new CloudQueueMessage($"Test {DateTime.Now}"));

This works fine, however what I need to do is put this code in a Nuget package. What bothers me is that I have to put the ConnectionString of my StorageAccount hard coded in that Nuget package. And this package will be used by 3rd party applications.

I could use an Azure Function with an HttpTrigger, but that kind of defeats the purpose of using a Queue.

What would be the best way to put something on a Queue from a Nuget package using a QueueTrigger, without exposing the ConnectionString of my Storage Account?

Or is my only option using a HttpTrigger in this case?

Upvotes: 0

Views: 171

Answers (1)

Rajdeep D
Rajdeep D

Reputation: 3910

You can check below 2 approaches,

  1. If you are using queue for load levelling purpose and do not want to expose your storage connection string then you can add another azure function which will just connect Nuget to Queue by http trigger and wrap storage connection string Nuget -> function (http trigger) -> Queue > function (queue trigger) -> ....

or

  1. You can use Azure key vault and store the storage connection string in key vault and access the connection string from nuget via service principle or any standard method

Upvotes: 0

Related Questions