我有一个 Azure 函数,它应该处理存储帐户容器中的文件。Azure 函数应该每天触发。但是每周一两次我看到容器中的一些文件没有被处理:(一开始 401 来自 600 的文件没有被处理,因为错误 403)
正如我在 Stackoverflow 中所读到的。这是因为 SAS 令牌时间偏差。是否有可能在我的代码没有大的改变的情况下解决这个问题?
我的代码:
CloudStorageAccount sa;
CloudStorageAccount.TryParse("MyConnString", out sa);
_blobClient = sa.CreateCloudBlobClient();
ICloudBlob sourceBlob = _blobClient.GetBlobReferenceFromServer(new Uri(BlobUrl));
更新
执行函数时出现消息异常:process_files_by_http_trigger_activity 远程服务器返回错误:(403)禁止。远程服务器返回错误:(403) Forbidden。
调用堆栈:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException:在 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+ 上的 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b7xxxx934e089) d__16.MoveNext(Microsoft.Azure.WebJobs.Host,版本=2.4.0.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35)在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken =b7xxxx934e089) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, 版本=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d__13.MoveNext (Microsoft.Azure .WebJobs.Host,版本=2.4.0.0,文化=中性,PublicKeyToken=31bfxxxx64e35) 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw 处处理的内部异常 Microsoft.WindowsAzure.Storage.StorageException:在 Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync(Microsoft.WindowsAzure.Storage,版本 = 7.2。 1.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35Microsoft.WindowsAzure.Storage,版本=7.2.1.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35:c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor \Executor.csMicrosoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bfxxxx64e35: 604) 在 Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetBlobReferenceFromServer (Microsoft.WindowsAzure.Storage, Version=7.2.1.0,文化=中性,PublicKeyToken=31bfxxxx64e35Microsoft.WindowsAzure.Storage,版本=7.2.1.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35:c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlobClient.csMicrosoft.WindowsAzure.Storage , 版本=7.2.1.0, 文化=中性, PublicKeyToken=31bfxxxx64e35: 563) 在 Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetBlobReferenceFromServer (Microsoft.WindowsAzure.Storage, 版本=7.2.1.0, Culture=neutral, PublicKeyToken=31bfxxxx64e35Microsoft。 WindowsAzure.Storage,版本=7.2.1.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35:c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlobClient.csMicrosoft.WindowsAzure.Storage,版本=7.2 .1.0,文化=中性,PublicKeyToken=31bfxxxx64e35:546)在 bip.dev.afu.inbound.we.process_xz_files_by_http_trigger.XzFileMove(bip.dev.afu.inbound.we,版本=1.0.0.0,文化=中性,PublicKeyToken=null)在 bip.dev.afu.inbound。 we.process_xz_files_by_http_trigger+d__10.MoveNext (bip.dev.afu.inbound.we, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0 , Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvokerPublicKeyToken=null) 在 bip.dev.afu.inbound.we.process_xz_files_by_http_trigger+d__10.MoveNext (bip.dev.afu.inbound.we, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) 在 System.Runtime。 CompilerServices.TaskAwaiter.ThrowForNonSuccess(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b7xxxx934e089)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b7xxxx934e089)在Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvokerPublicKeyToken=null) 在 bip.dev.afu.inbound.we.process_xz_files_by_http_trigger+d__10.MoveNext (bip.dev.afu.inbound.we, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) 在 System.Runtime。 CompilerServices.TaskAwaiter.ThrowForNonSuccess(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b7xxxx934e089)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b7xxxx934e089)在Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvokerCulture=neutral, PublicKeyToken=b7xxxx934e089) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvokerCulture=neutral, PublicKeyToken=b7xxxx934e089) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker
2+<InvokeAsync>d__2.MoveNext (Microsoft.Azure.WebJobs.Host, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bfxxxx64e35) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess 的 2+d__9.MoveNext(Microsoft.Azure.WebJobs.Host,Version=2.4.0.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35)(mscorlib,Version=4.0.0.0,Culture=neutral , PublicKeyToken=b7xxxx934e089) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d__24.MoveNext (Microsoft .Azure.WebJobs.Host, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bfxxxx64e35) 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在系统.Runtime.CompilerServices.TaskAwaiter。Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d__23.MoveNext 上的 HandleNonSuccessAndDebuggerNotification(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b7xxxx934e089)(Microsoft.Azure.WebJobs.Host,版本=2.4.0.0,Culture =中性,PublicKeyToken=31bfxxxx64e35)在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(mscorlib,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b7xxxx934e089)在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(mscorlib,版本=4.0 .0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d__22.MoveNext (Microsoft.Azure.WebJobs.Host, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bfxxxx64e35)在 System.Runtime.CompilerServices.TaskAwaiter。ThrowForNonSuccess (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7xxxx934e089) 在 System.Runtime。 CompilerServices.TaskAwaiter.ValidateEnd(mscorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b7xxxx934e089)
在 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d__16.MoveNext (Microsoft.Azure.WebJobs.Host, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bfxxxx64e35) 内部异常 System.Net.WebException 在 Microsoft 处理。 WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync:
在 System.Net.HttpWebRequest.GetResponse(系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b7xxxx934e089)在 Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync(Microsoft.WindowsAzure.Storage,版本=7.2。 1.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35Microsoft.WindowsAzure.Storage,版本=7.2.1.0,Culture=neutral,PublicKeyToken=31bfxxxx64e35:c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor \Executor.csMicrosoft.WindowsAzure.Storage,版本=7.2.1.0,文化=中性,PublicKeyToken=3xxxxx6ad364e35:677)