2
votes

I have an Azure durable function triggered by a message that then uses the client to start an Orchestration trigger which starts several activity functions. I have set breakpoints in Orchestration client , trigger and each activity function. But, it only hits the breakpoints in Orchestration client function and the others are getting ignored. But underneath it seems to execute the activity functions although the breakpoints are not hit.

Investigative information

  • Programming language used = C#
  • Visual Studio Enterprise 2019 version = 16.8.3
  • Azure Functions Core Tools Core Tools Version: 3.0.3216 Function Runtime Version: 3.0.15193.0

Below here, I have included a code snippet. (have not added every activity function)

[FunctionName(nameof(InitiateExport))]
        public static async Task InitiateExport(
            [ServiceBusTrigger("%ExportQueueName%", Connection = "AzureSBConnection")]Message message,
            [DurableClient(TaskHub = "%FunctionHubName%")] IDurableOrchestrationClient orchestrationClient,
            [Inject]IServiceProvider rootServiceProvider, ILogger log)
        {
            var DataQueuedDetails = JsonConvert.DeserializeObject<DataQueuedDetails>(Encoding.UTF8.GetString(message.Body));

            using (var scope = rootServiceProvider.CreateScope())
            {
                log.LogInformation($"{nameof(ExportData)} function execution started at: {DateTime.Now}");
                
                var services = scope.ServiceProvider;
                services.ResolveRequestContext(message);
                var requestContext = services.GetRequiredService<RequestContext>();

                await orchestrationClient.StartNewAsync(nameof(TriggerDataExport), null, (DataQueuedDetails, requestContext));

                log.LogInformation($"{nameof(ExportData)} timer triggered function execution finished at: {DateTime.Now}");
            }
        }    

[FunctionName(nameof(TriggerDataExport))]
        public static async Task TriggerDataExport(
            [OrchestrationTrigger] IDurableOrchestrationContext orchestrationContext,
            [Inject] IServiceProvider rootServiceProvider, ILogger log)
        {

     using (var scope = rootServiceProvider.CreateScope())
            {               

                var services = scope.ServiceProvider;
                var (DataOperationInfo, requestContext) = orchestrationContext.GetInput<(DataQueuedDetails, RequestContext)>();
                
                if (!orchestrationContext.IsReplaying)
                    log.LogInformation($"Starting Export data Id {DataOperationInfo.Id}");
                
                var blobServiceFactory = services.GetRequiredService<IBlobServiceFactory>();
                requestContext.CustomerId = DataOperationInfo.RelatedCustomerId;
                
                try
                 {                       
                        await orchestrationContext.CallActivityAsync(
                             nameof(UpdateJobStatus),
                             (DataOperationInfo.Id, DataOperationStatus.Running, string.Empty, string.Empty, requestContext));
                    
                     // some other activity functions
                  ---
                  ---
                } catch (Exception e)
                {                   
                    await orchestrationContext.CallActivityAsync(
                        nameof(UpdateJobStatus),
                        (DataOperationInfo.Id, DataOperationStatus.Failed, string.Empty, string.Empty, requestContext));
                    
                }
          }
}

[FunctionName(nameof(UpdateJobStatus))]
        public static async Task RunAsync(
            [ActivityTrigger] IDurableActivityContext activityContext,
            [Inject]IServiceProvider rootServiceProvider)
        {
            using (var scope = rootServiceProvider.CreateScope())
            {
                try
                {
                    var (DataOperationId, status, blobReference, logFileBlobId, requestContext) = activityContext.GetInput<(string, string, string, string, RequestContext)>();
                    var services = scope.ServiceProvider;
                    services.ResolveRequestContext(requestContext.CustomerId, requestContext.UserId, requestContext.UserDisplayName, requestContext.Culture);
                    var dataService = services.GetRequiredService<IDataService>();
                    var DataOperationDto = new DataOperationDto
                    {
                        Id = DataOperationId,
                        OperationStatusCode = status,
                        BlobReference = blobReference,
                        LogBlobReference = logFileBlobId
                    };
                    await dataService.UpdateAsync(DataOperationDto);
                }
                catch (Exception e)
                {
                    throw e;
                }
                
            }
        }
                
1
how about you start by sharing some relevant source code? How else should anybody help you?silent
@silent, I updated my post with the codeHirSK
While you are debugging your Function, are you using a local storage emulator? Or an actual Storage Account that might also be used by the Function already deployed in Azure? then it could be, that parts of the execution is actually happening in Azure instead of your dev machinesilent
@silent yes I'm using the actual storage. Do you mean that I need to disable the Function deployed in Azure? Thank you very much for responding. I'll take a look on thatHirSK
Yes, either that or, what I would rather recommend, use a different storage account for dev/debuggingsilent

1 Answers

3
votes

While you are debugging your Function, you should make sure that you are either using the local storage emulator, or an Azure Storage Account that is different from the one that is also being used by the Function already deployed in Azure.

If you are using the same storage account that another running Function is using, then it could be that parts of the execution is actually happening in Azure instead of your dev machine.