question

AleksandarLozanovski-5544 avatar image
0 Votes"
AleksandarLozanovski-5544 asked MayankBargali-MSFT answered

Get-AzWebAppSnapshot throws "String 'MM/dd/yyyy ss:mm:ss' was not recognized as a valid DateTime" error when executed in Azure function app

I'm attending to write powershell script to do some automation and it works fine when executed, but when I put my script in a Function App (powershell)
I get this error:


ERROR: String '05/27/2021 00:01:38' was not recognized as a valid DateTime.

This error is thrown when executing command:

 $snapshots = Get-AzWebAppSnapshot -ResourceGroupName $AppServicePlanResourceGroup -Name $WebAppName;

$AppServicePlanResourceGroup and $WebAppName have valid values.

My Function app settings:
Runtime version: ~3
Stack: PowesShell Core
PowerShell Core Version: PowerShell 7.0
Az Module Version: 'Az' = '6.*'

azure-functions
· 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.

@AleksandarLozanovski-5544 Apology for the delay in reaching out. Can you share the failed invocation ID along with the timeframe in UTC and the region where your function app is deployed. Is the issue intermittent?

0 Votes 0 ·

It seems that this issue is intermittent. I've tried again and it works properly in West Europe region.
But when I execute the same script (the same function) whit the same payload locally, it throws this error.

ERROR: String '06/13/2021 14:32:13' was not recognized as a valid DateTime.
[2021-07-01T15:56:03.613Z]
[2021-07-01T15:56:03.613Z] Exception :
[2021-07-01T15:56:03.613Z] Type : System.FormatException
[2021-07-01T15:56:03.613Z] TargetSite :
[2021-07-01T15:56:03.613Z] Name : Parse
[2021-07-01T15:56:03.613Z] DeclaringType : System.DateTimeParse, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx
[2021-07-01T15:56:03.613Z] MemberType : Method
[2021-07-01T15:56:03.613Z] Module : System.Private.CoreLib.dll
[2021-07-01T15:56:03.613Z] StackTrace :
[2021-07-01T15:56:03.613Z] at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
[2021-07-01T15:56:03.613Z] at System.DateTime.Parse(String s)

Successfully executed command retrieves list of snapshots, and I have this element in the list:

 {
     "ResourceGroupName": "rg-factory-dev-clients-win",
     "Name": "webapp-dev-....",
     "Slot": "Production",
     "SnapshotTime": "2021-06-13T14:32:13"
 },

It seems that parsing SnapshotTime value is what makes the problem.
The only difference is that azure function app is hosted on
OS: Microsoft Windows 10.0.14393
Platform: Win32NT
My local function app is running on
OS:Darwin 20.3.0 Darwin Kernel Version 20.3.0
Platform Unix

0 Votes 0 ·
MayankBargali-MSFT avatar image MayankBargali-MSFT AleksandarLozanovski-5544 ·

@AleksandarLozanovski-5544 Thanks for your response. I have tried to repro it locally but couldn't reproduce the issue. Can you respond to my private comment to share the logs so I can assist you further.

0 Votes 0 ·

1 Answer

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered

This looks specific to the environment on mac machine and the issue can be tracked here.

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.