Skip to content

Conversation

@navba-MSFT
Copy link
Contributor

@navba-MSFT navba-MSFT commented Feb 24, 2022

This conversion to localtime should fix the conversion issue due to localization format

Description

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md

  • The title of the PR is clear and informative

  • The appropriate ChangeLog.md file(s) has been updated:

    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes

  • If applicable, the changes made in the PR have proper test coverage

  • For public API changes to cmdlets:

    • a cmdlet design review was approved for the changes in this repository (Microsoft internal only)
      • {Please put the link here}
    • the markdown help files have been regenerated using the commands listed here

    More Info:

    When running the cmdlet with non en-US (at least, in pl-PL culture) the cmdlet fails with example error:
    String '01/24/2022 22:52:39' was not recognized as a valid DateTime.
    Output of:
    [system.threading.thread]::CurrentThread.CurrentCulture
    LCID Name DisplayName
    1045 pl-PL Polish (Poland)

Steps to reproduce:

  1. Run the below command in your Powershell:
    [system.threading.thread]::CurrentThread.CurrentCulture = [System.Globalization.CultureInfo]::GetCultureInfo("pl-PL")
    Get-AzWebAppSnapshot -ResourceGroupName $SourceRG -Name $WebAppName

This fails with the error: String '01/24/2022 22:52:39' was not recognized as a valid DateTime.

  1. When changing CurrentThread.CurrentCulture to en-US it works OK.

This conversion to localtime should fix the conversion issue due to localization format
@BethanyZhou
Copy link
Contributor

BethanyZhou commented Feb 24, 2022

Hi @navba-MSFT, have you figure out the root cause of this issue? I would like to suggest you to fix this issue by SnapshotTime = DateTime.Parse(s.Time,CultureInfo.InvariantCulture) , because I think s.Time should be an UTC-format string.

Fix for the DateTime.Parse(s.Time) to address the localization issue and avoid the error String was not recognized as a valid DateTime
@BethanyZhou
Copy link
Contributor

Hi @navba-MSFT , a test case is failed, please have a look.

[xUnit.net 00:01:00.29] Microsoft.Azure.Commands.Websites.Test.ScenarioTests.CertificatesTests.TestNewAzWebAppCertificateForSlot [FAIL]

@BethanyZhou
Copy link
Contributor

/azp run azure-powershell - windows-powershell

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@BethanyZhou
Copy link
Contributor

/AZP RUN azure-powershell - security-tools

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

BethanyZhou
BethanyZhou previously approved these changes Mar 1, 2022
Copy link
Contributor

@BethanyZhou BethanyZhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@navba-MSFT
Copy link
Contributor Author

@BethanyZhou Thanks for reviewing this. Could you merge this once you get a chance ?

@BethanyZhou
Copy link
Contributor

/azp run azure-powershell - security-tools

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@BethanyZhou
Copy link
Contributor

Sure, I will merge it when the CI passed. @navba-MSFT

@BethanyZhou BethanyZhou merged commit 83a1cf8 into Azure:main Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants