简体   繁体   English

Azure Table Storage query failed with authentication error (Received:Forbidden) 不时出现

[英]Azure Table Storage query failed with authentication error (Received:Forbidden) from time to time

Environment: Azure app service.环境:Azure app服务。

Azure storage SDK: WindowsAzure.Storage (9.3.3) Azure 存储 SDK: WindowsAzure.Storage (9.3.3)

Invocation (pseudo code):调用(伪代码):

void QueryAzureTable(){
    while(true){
        var tableClient = new AzureTable();
        var resp = tableClient.Query('table','pk','rk');
        // ...
    }
}

var tasks = new List<Task>();
for (var i = 0; i < 5; i++)
{
    tasks.Add(QueryAzureTable());
}
await Task.WhenAll(tasks).ConfigureAwait(false);

Authorization method for QueryAzureTable: tried with both clientId/secret and managed identity/MSI, same result for both. QueryAzureTable 的授权方法:尝试使用 clientId/secret 和托管身份/MSI,两者的结果相同。

Observation:观察:

  1. Around half of the requests failed due to anth issue in QueryAzureTable() (see detailed error msg below).由于QueryAzureTable()中的 anth 问题,大约一半的请求失败(请参阅下面的详细错误消息)。
  2. If I restart the azure app service instance, the auth error will be gone for ~12 hours.如果我重新启动 azure 应用程序服务实例,身份验证错误将消失约 12 小时。

Error Message:错误信息:

  1. Server failed to authenticate the request.服务器无法验证请求。 Make sure the value of Authorization header is formed correctly including the signature.确保正确形成授权 header 的值,包括签名。
  2. Unexpected response code, Expected:OK or NotFound, Received:Forbidden意外的响应代码,预期:OK 或 NotFound,收到:Forbidden

I have checked and tried with almost every solutions mentioned in this stackoverflow thread , but no luck.我已经检查并尝试了此stackoverflow 线程中提到的几乎所有解决方案,但没有成功。 Guess this specific auth issue might be related with multi-tasks.猜测这个特定的身份验证问题可能与多任务有关。

Kind of figured out the solution on my own: adding a retry logic to renew the token .我自己想出了解决方案:添加重试逻辑来更新令牌

void query(...){
    int cnt=0;
    while(true){
        try{
            _client.queryTable(...);
        }
        catch(AuthException ex){
            log.error(ex...);
            var token=new Token(...);
            _client = new AzureTableClient(token);
            cnt++;
            if(cnt==3) throw;
        }
    }
}

The first clue to this solution was whenever there was a app service release, deployment or restart of the app service, the query table function worked well for a while, and then after around 12 hours, errors started showing up.这个解决方案的第一个线索是每当有应用服务发布、部署或重启应用服务时,查询表 function 运行了一段时间,然后大约 12 小时后,错误开始出现。 But not 100% failure rate.但不是100%的失败率。

If there is any explanation or conclusion that helps to root cause this, please share your opinions.如果有任何解释或结论有助于根本原因,请分享您的意见。 Thanks in advance: My blind guess is that it has something to do with muti-tasks.在此先感谢:我的盲目猜测是它与多任务有关。 WindowsAzure.Storage (9.3.3) does not do a good job of renewing token for muti-tasks. WindowsAzure.Storage (9.3.3) 不能很好地为多任务更新令牌。

Hope this could help you.希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法访问 Pulumi 创建的 Azure 存储表 - 禁止访问 (403) - Unable to access a Pulumi Created Azure Storage Table - Access Forbidden (403) 如何锁定 Azure 存储表中的项目,一次只允许一个 Azure function 访问其数据 - How to lock item in Azure storage table to allow only one Azure function to access its data at a time 带有 Azure 表存储的错误 Databricks Scala 应用程序 - Error Databricks Scala Application with Azure Table Storage 无法使用 Azure CLI 查询 Azure 表存储 - Unable to query Azure Table Storage using Azure CLI 逻辑应用查询 Azure Table 使用 HTTP 和 Managed Identity 认证 - Logic App query Azure Table using HTTP and Managed Identity authentication 403 文件上传时收到禁止的错误 - 403 Forbidden error is received on file upload Azure Git 认证失败 - Authentication failed for Azure Git 递归提供 ACL 访问 Azure 存储容器:耗时 - Recursively provisioning ACL access over Azure Storage container : time consuming 尝试从 Firebase 存储加载图像时出现 403 禁止错误 - Getting 403 Forbidden error when trying to load image from Firebase Storage 在 Azure 表存储中跨实体查询的最佳方式 - Best way to query across entities in Azure Table Storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM