Results in a date format not recognized by the Get-SHRLatestImageVersion.ps1. This is because the RegEx expects a year format of 24 instead of 2024. But the Image Version provided above results in 2024, resulting in an error when running the Function App.
So I changed this code:
if ($azImageVersion -match "\d+\.\d+\.(?<Year>\d{2})(?<Month>\d{2})(?<Day>\d{2})") {
$azImageDate = Get-Date -Date ("20{0}-{1}-{2}" -f $Matches.Year, $Matches.Month, $Matches.Day)
Write-PSFMessage -Level Host -Message "Image date is {0}" -StringValues $azImageDate
}
else {
throw "Image version does not match expected format. Could not extract image date."
}
With this code:
if ($azImageVersion -match "^(?<Year>\d{2}|\d{4})\.(?<Month>\d{2})\.(?<Day>\d{2})$") {
if ($Matches.Year.Length -eq 2) {
$year = (Get-Date -Format "yyyy").Substring(0,2) + $Matches.Year
} else {
$year = $Matches.Year
}
$azImageDate = Get-Date -Date ("{0}-{1}-{2}" -f $year, $Matches.Month, $Matches.Day)
Write-PSFMessage -Level Host -Message "Image date is {0}" -StringValues $azImageDate
} else {
throw "Image version does not match expected format. Could not extract image date."
}
Perhaps you can use it in this project or provide me with feedback to even solve this in a better way?
Hi,
Today I discovered that using this image:
Results in a date format not recognized by the Get-SHRLatestImageVersion.ps1. This is because the RegEx expects a year format of 24 instead of 2024. But the Image Version provided above results in 2024, resulting in an error when running the Function App.
So I changed this code:
With this code:
Perhaps you can use it in this project or provide me with feedback to even solve this in a better way?