question

PriyaSinha-9031 avatar image
0 Votes"
PriyaSinha-9031 asked MughundhanRaveendran-MSFT commented

function App throwing Exception while calling ADO REST API and same API works Successfully in Local Powershell

hi Team,

I have created a Powershell module and I installed it locally to run some REST API. All the calls are successful when I run it locally while if i run it through Azure Function it gives me below exception

2022-04-29T20:39:39.174 [Error] ERROR: :


at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)

Exception :
Type : Microsoft.PowerShell.Commands.WriteErrorException
Message : :


at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
HResult : -2146233087
CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException

azure-functions
· 1
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 @PriyaSinha-9031,
Can you share more details regarding how you invoke this "ADO REST API" inside the Azure Function?
If I understand you managed to query the api using PowerShell but it is not working when you try inside a Azure function.

The error that you posted seems to be a PowerShell error.

what type of authentication is this api using? How do you invoke inside the azure function?



0 Votes 0 ·

1 Answer

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

@PriyaSinha-9031 ,

Thanks for reaching out to Q&A.

First you need to make sure that the powershell module that you are using is compatible with Poweshell core. Minimum supported powershell version in Azure functions is 6 but we recommend 7 as it is the latest version. So I would suggest you to test the module in powershell core and then deploy it to Azure functions once you have confirmed it's working in PS core as expected.

I would suggest you to provide more details about the exception (full stack trace along with the line of script that throws exception) so that it would be helpful to provide a solution. Looking at the exception type Microsoft.PowerShell.Commands.WriteErrorException, it appears that you are trying to write something to a file system. Please note that, writing to a file system might be restricted in Azure functions as it is a sandboxed environment. Please refer to this document for more details.


· 3
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 Guys, Thanks for your response.
I was getting this error entire day on Friday. I ran it today and is not throwing the exception anymore.
Do you know if there was any downtime in Azure function, any kind of deployment /change in functionApp which could affect this ?
I am really curious to know as I spent almost half of the day trying to figure this out

0 Votes 0 ·

@PriyaSinha-9031 , Please check the Diagnose and solve problems blade in the Function portal. Run "Function app down or reporting errors" detector to get any information about downtime/exceptions

https://docs.microsoft.com/en-us/azure/azure-functions/functions-diagnostics

1 Vote 1 ·
MughundhanRaveendran-MSFT avatar image MughundhanRaveendran-MSFT MughundhanRaveendran-MSFT ·

@PriyaSinha-9031 , Following up to see if the above comment was helpful. Please let me know.

0 Votes 0 ·