2

I have a problem with azure function only when I publish.

the code run not in order, all the functions run at the same time.

ex :

var logger = context.GetLogger(nameof(MibProposalRequest));
        logger.Log(LogLevel.Warning, $"Début de la fonction : MibProposalRequest {DateTime.UtcNow}");
        
        try
        {
            var getStringResponse = await this.GetStringAsync(req, logger).ConfigureAwait(false);
            if (getStringResponse.Error != null)
            {
                return new HttpResponseMessage()
                {
                    StatusCode = getStringResponse.Error.StatusCode,
                    ReasonPhrase = getStringResponse.Error.Message
                };
            }
            else
            {
                var requestBody = getStringResponse.Response.ToString();
                var deserializeRequestBodyResponse = await this.DeserializeRequestBodyAsync(requestBody, logger).ConfigureAwait(false);
                if (deserializeRequestBodyResponse.Error != null)
                {
                    return new HttpResponseMessage()
                    {
                        StatusCode = deserializeRequestBodyResponse.Error.StatusCode,
                        ReasonPhrase = deserializeRequestBodyResponse.Error.Message
                    };
                }

In this example I need to get the response of the function GETStringAsync and after go to the function : DeserializeRequestBodyAsync.

If I run the azure function in local (debug) it's all ok, everything it's in order. First log the function start. After Get the string end deserializeObject.

But when I publish the function and I test it, when I'm loocking at the log in portal.azure. All the function run not in good order. So sometimes I get an error from deserializeObject function because no string to deserialize. But its suppose to do the GetStringAsync function first.

Why this append? Image of the log

as you can see the function start log is not the first to show up why ? looks like all the code run completely not in order.

should be like this : Log of vs debug

Everything is good each functions run in good order (so no problems)

Why this append only when the function is published ??

Ps: I tried to run the function not async but nothing change. PS2: I tried to put all the code in the same function (Run) nothing changed. PS3: I tried to put task.wait nothing changed.

I need help please 2 days I'm on this.

2
  • The code execution order does not change, but you may be seeing the results of multiple concurrent executions of your function. There's not enough code posted to tell. So try to post a simplified, self-contained example. Commented Nov 7, 2021 at 0:14
  • Inside the azureFunction I have a couples methods ok ????!!! FunctoinOne FunctionTwo FunctionThree I need to do it in this order 1 2 3 not 2 1 3 Commented Nov 7, 2021 at 0:32

2 Answers 2

1

https://azure.microsoft.com/en-us/updates/general-availability-azure-functions-supports-net-5-in-production/?cdn=disable

From my experience this was a pain to get to work with Azure Functions on .NET 5. Either roll back to 3.1 or wait till 11/9/2021 for .NET 6 to release out of preview. .NEt 6 preview is allowed on Azure for testing.

Are you running .NET 5 in Azure in isolated mode? See link above.

"To support .NET 5, Azure Functions introduces a new isolated process model that runs .NET function apps in a separate worker process outside the Azure Functions host runtime."

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

2 Comments

The problem it's i'm using some project in my solution use the net 5.
The function works but looks like all the methods inside run all together not in good order.
0

I just found a solution in the code:

 List<ProposalIdModel> list = (List<ProposalIdModel>)deserializeGuidsAsyncResponse.Response ?? new List<ProposalIdModel>();

Like this the list while never be null. But it's wired in visual studio in debug no problem, but when I publish sometime the list get null. So problem solved. I also update to netCore6.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

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.