问题:将消息启动到Azure存储队列不使用托管身份

发布于 2025-01-24 13:12:39 字数 350 浏览 2 评论 0原文

C#Azure函数应用程序之一生成消息并将其放在Azure存储队列中,我们想使用托管身份,因为我们不想使用配置中的连接字符串。

创建的用户分配的托管身份 提供所需的RBAC角色,例如存储Blob数据所有者&存储队列数据贡献者在存储中。 (我们尝试了其他角色,例如撰稿人,所有者) 我们正在使用Microsoft.azure.webjobs.extensions.storage 5.0.0版本。我们遵循文档中提到的所有步骤/说明(开发Azure函数的指南| Microsoft文档)。

在将消息从功能应用程序中加入Azure存储队列时,它正在转移到毒药队列中,而不是主队列,并且同样的是无问题的连接字符串。要求您让我们知道您是否需要任何其他详细信息。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里°也失望 2025-01-31 13:12:40

在将消息从功能应用程序中加入Azure存储队列时,它正在移动到毒药队列,而不是主排队,并且同样的是无问题的连接字符串。

  • 这是一个样品用于转移毒药队列的解决方案返回存储帐户的消息
  • 将下面的nuget软件包添加到您的参考文献中,
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;

}

  • 请参阅此 so 以获取完整的信息。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文