Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何知道服务总线触发功能是否成功完成?_C#_.net_Azure_Azure Functions_Azureservicebus - Fatal编程技术网

C# 如何知道服务总线触发功能是否成功完成?

C# 如何知道服务总线触发功能是否成功完成?,c#,.net,azure,azure-functions,azureservicebus,C#,.net,Azure,Azure Functions,Azureservicebus,我的功能是否已成功完成处理? 在0.01%的时间内,我看到以下例外情况: Microsoft.Azure.WebJobs.Host.FunctionInvocationException:位于 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at Microsoft.Azur

我的功能是否已成功完成处理?

在0.01%的时间内,我看到以下例外情况:

Microsoft.Azure.WebJobs.Host.FunctionInvocationException:位于 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d_u19.MoveNext (Microsoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, 版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.azure.webjobs.Host\Executors\FunctionExecutor.csMicrosoft.azure.webjobs.Host, 版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35: 293)在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter
1.GetResult(System.Private.CoreLib,版本=4.0.0.0,区域性=neutral,PublicKeyToken=7cec85d7bea7798e),位于Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+d_16.MoveNext(Microsoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35:C:\projects\Azure-WebJobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35:97)内部异常Microsoft.WindowsAzure.Storage.StorageException在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw处理:在Microsoft.WindowsAzure.Storage.Core.Executor.Executor+d_4
1.MoveNext (Microsoft.WindowsAzure.Storage,版本=9.3.1.0,区域性=中性, PublicKeyToken=31bf3856ad364e35)在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at Antrox.Antrox_dg_func_dev+d_0.MoveNext(Antrox,版本=1.0.0.0, 区域性=中性,PublicKeyToken=Nullantox,版本=1.0.0.0, 区域性=中性,PublicKeyToken=空: C:\sourcecode\Interfaces\Alidade\Antrox\MAIN\Antrox\Antrox\u dg\u func\u dev.csAntrox, 版本=1.0.0.0,区域性=中立,PublicKeyToken=null:67)位于 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter.ThrowForNonSuccess (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at System.Runtime.CompilerServices.TaskWaiter.GetResult (System.Private.CoreLib,版本=4.0.0.0,区域性=中性, PublicKeyToken=7cec85d7bea7798e)at Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker
2+d\u 2.MoveNext(Microsoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35:C:\projects\Azure-WebJobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\VoidTaskMethodInvoker.csMicrosoft.Azure.WebJobs.Host,版本=3.0.23.0,Cul)true=neutral,PublicKeyToken=31bf3856ad364e35:20)在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e)在System.Runtime.CompilerServices.awaitter.ThrowForNonSuccess(System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Private.CoreLib,Version=4.0.0.0,Culture=neutral,Culture=neutral,PublicKeyToken=7cec85d7bea7798e)在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Private.Corelibe.CoreLib,Version=4.0.0.0.0.0.0,Culture=neutral,PublicKeyToken
(System.Private.CoreLib,版本=4.0.0.0,区域性=中性,
PublicKeyToken=7cec85d7bea7798e)at
Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker
2+d\u 10.MoveNext(Microsoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=中性,PublicKeyToken=31bf3856ad364e35:C:\projects\Azure-WebJobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.csMicrosoft.Azure.WebJobs.Host,版本=3.0.23.0,区域性=n)eutral,PublicKeyToken=31bf3856ad364e35:52)在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e)在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification,System.Private.CoreLib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e)在System.Runtime.CompilerServices(System.Private.CoreLib,Version=4.0.0.0.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e)
namespace aaa {
    public static class aaa_dg_func_dev {
        [FunctionName ("CheckMessageServiceBusTopicTriggered")]
        public static async Task Run ([ServiceBusTrigger (
                "%Topic%",
                "%Subscription%",
                Connection = "ServiceBus")] string @in, [Table ("%HashTable%", "%InboundInterfaceProperty%", Connection = "StorageConnectionString")] CloudTable hashes, [ServiceBus ("%OutputTopic%", Connection = "ServiceBus", EntityType = EntityType.Topic)] IAsyncCollector<Message> bus,
            IDictionary<string, object> UserProperties,
            string messageId,
            ILogger log) {
            var sourceKey = GetEnvironmentVariable ("InboundInterfaceKey");
            var sourceFileKey = GetEnvironmentVariable ("SourceFileNameKey");
            var threshold = GetEnvironmentVariable ("threshold");
            var sourceFile = UserProperties[sourceFileKey].ToString ();
            var source = UserProperties[sourceKey].ToString ();
            var hash = Hash (@in);
            var now = DateTime.Now;
            var @out = new Message {
                Body = System.Text.Encoding.UTF8.GetBytes (@in),
                MessageId = messageId
            };
            @out.UserProperties.Add (sourceKey, source);
            @out.UserProperties.Add (sourceFileKey, sourceFile);

            var get = Retrieve<MessageHash> (source, hash);
            var hashResult = await hashes.ExecuteAsync (get);

            //If there are no records found, then insert and send message
            if (hashResult.Result == null) {
                var hashMessage = new MessageHash (source, hash, now.ToString (), sourceFile);
                var insert = Insert (hashMessage);
                await hashes.ExecuteAsync (insert);
                await bus.AddAsync (@out);
                return;
            }

            //Perform upsert operation on existing hash to update lastmodified
            var thresholdEnd = now;
            var thresholdStart = now.AddDays (-int.Parse (GetEnvironmentVariable ("threshold")));
            var found = (MessageHash) hashResult.Result;
            var orgLastModified = DateTime.Parse (found.LastModified);
            found.LastModified = now.ToString ();
            found.SourceFileName = sourceFile;
            var upsert = Replace (found);
            await hashes.ExecuteAsync (upsert);
            //Return if we are within the threshold
            if (orgLastModified >= thresholdStart && orgLastModified <= thresholdEnd) {
                return;
            }

            //Send message
            await bus.AddAsync (@out);
        }
    }
}