0

One of the C# Azure Function App generates messages and put them in azure storage queue, and we would like to use the Managed Identity as we don't want to use the connection strings in the configuration.

Created User Assigned Managed Identity Provided required RBAC roles like Storage Blob Data Owner & Storage Queue Data Contributor on the storage . ( We tried even with other roles like Contributor , Owner) We are using Microsoft.Azure.WebJobs.Extensions.Storage 5.0.0 version. We followed all the steps/instructions as mentioned in the docs (Guidance for developing Azure Functions | Microsoft Docs) .

While enqueueing the message to azure storage queue from the function app, it is moving to poison queue instead main queue and the same is working the connect string without any issues. Request you to let us know if you need any additional details.

  • Hi, do you have any logs regarding any error that would move the message into the poison queue ? – Thomas Apr 27 '22 at 19:58

1 Answers1

0

While enqueueing the message to azure storage queue from the function app, it is moving to poison queue instead main queue and the same is working the connect string without any issues.

  • Here is a Sample solution for transferring Poison Queue Messages back to storage account
  • Add the Below Nuget package to your reference
using Microsoft.WindowAzure.Storage;
using Microsoft.windowsazure.Storage.Queue;

void main()
{
 const string queuename ="MyQueuename";

string storageAccountString = "xxxxxx";

RetryPoisonMessages(storageAccountString,queuename);
} 

private static int RetryPoisonmessages(string storageAccountString, string queuename)
{
 CloudQueue targetqueue=GetCloudQueueRef(storageAccountString,Queuename);

CloudQueue poisonqueue=GetCloudQueueRef(storageAccountString,Queuename+ "-poison");

int count=0;
while(true)
{
  var msg =poisonqueue.GetMessage();
   if(msg == null)
     break;
 
poisonqueue.DeleteMessage(msg);
targetqueue.AddMessage(msg);
count++
}
return count;
}
private static cloudQueue GetCloudQueueRef( string storageAccountString, string queuename)
{
CloudSytorageAccount storageAccount =CloudStorageAccount.Parse(storageAccountString);
CloudQueueClient queueClient = storageAccount.CreateCloudclient();
CloudQueue queue =QueueClient.GetQueueReference(queuename);

return queue;

}

  • Refer this SO for complete information.
SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15