HirSK
HirSK

Reputation: 73

Azure Orchestration Trigger breakpoints not hit

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

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;
                }
                
            }
        }
                

Upvotes: 4

Views: 1256

Answers (1)

silent
silent

Reputation: 16198

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.

Upvotes: 4

Related Questions