4

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;
                }
                
            }
        }
                
9
  • how about you start by sharing some relevant source code? How else should anybody help you? Commented Jan 8, 2021 at 13:03
  • @silent, I updated my post with the code Commented Jan 8, 2021 at 13:21
  • 1
    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 machine Commented Jan 8, 2021 at 13:49
  • @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 that Commented Jan 8, 2021 at 14:48
  • Yes, either that or, what I would rather recommend, use a different storage account for dev/debugging Commented Jan 8, 2021 at 14:50

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm really grateful for your quick response. This was the problem I was having.
sure thing. please mark the answer as accepted if this solved it for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.