question

ObaidUrRehman-9153 avatar image
0 Votes"
ObaidUrRehman-9153 asked ShaikMaheer-MSFT commented

Getting request status code from azure function in adf

Hi,

I have a web activity in adf that calls an azure function.

The azure function code returns either

 return func.HttpResponse(f"Function call executed., status_code=200)

OR

  return func.HttpResponse(
              "Invalid arguments provided.",
              status_code=202
         )

But in the adf output I only see this:

196512-adfazf.png

Is there any way to mark this activity as passed or failed based on the status code returned from the azure func? Also, I do not see any status code in the web activity output.


azure-data-factory
adfazf.png (33.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ShaikMaheer-MSFT avatar image
0 Votes"
ShaikMaheer-MSFT answered ShaikMaheer-MSFT commented

Hi @ObaidUrRehman-9153 ,

Thank you for posting query in Microsoft Q&A Platform.

As I understand your query, you are looking for ways to mark web activity execution to pass of fail based on Response you get from Azure Function. Please correct me if I am wrong.

Here web activity done with its job of calling API and got some response back too. Hence, web activity always marks it as successful only. Until or unless if it sees any timeout issue or unable to reach API and all.

So, based on response you get, you should consider hitting Fail activity to take your execution accordingly. Fail activity makes entire pipeline status to fail. This video also explains fail activity.

Below high-level logic shows implementation of same.
196869-image.png

Hope this helps. Please let us know if any further queries.


Please consider hitting Accept Answer button. Accepted answers help community as well.


image.png (113.9 KiB)
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

Thanks for the reply. I understand what you mean, but there is no status returned by the azure function call. It just has the text plz check the image attached.
196999-cont.png

Where as in the azure function code I am returning this:

 return func.HttpResponse(
              "Invalid arguments provided.",
              status_code=202
         )

How do I access the status code, so I can use if else on that.


0 Votes 0 ·
cont.png (20.2 KiB)

Hi @ObaidUrRehman-9153 , The Response property text what we see in the output json is actually coming from Azure function only. So, I was trying to say to have IF activity condition on that text itself. We can also consider sending status code as part of response. That should also fine. Either way which suits for your requirements.

Hope this helps. Please let us know if any further queries.


Please consider hitting Accept Answer button. Accepted answers help community as well.

0 Votes 0 ·

Perfect. Thanks.

I cant see "Accept Answer" button on this page, wierd!

0 Votes 0 ·
Show more comments