diff --git a/src/Functions/Functions.Autorest/README.md b/src/Functions/Functions.Autorest/README.md index 03940dfa3885..c613df53bd0e 100644 --- a/src/Functions/Functions.Autorest/README.md +++ b/src/Functions/Functions.Autorest/README.md @@ -66,7 +66,7 @@ directive: ``` ``` yaml -commit: d9f06f3de6cb00796a91b86b622dcf50340952a2 +commit: 8d63f74cf23671439c042599883f910800e3eeed require: - $(this-folder)/../../readme.azure.noprofile.md input-file: diff --git a/src/Functions/Functions.Autorest/custom/FunctionsStack/functionAppStacks.json b/src/Functions/Functions.Autorest/custom/FunctionsStack/functionAppStacks.json index c2447258d88e..5f67732eac8b 100644 --- a/src/Functions/Functions.Autorest/custom/FunctionsStack/functionAppStacks.json +++ b/src/Functions/Functions.Autorest/custom/FunctionsStack/functionAppStacks.json @@ -8,6 +8,80 @@ "value": "dotnet", "preferredOs": "windows", "majorVersions": [ + { + "displayText": ".NET 9 Isolated", + "value": "dotnet9isolated", + "minorVersions": [ + { + "displayText": ".NET 9 Isolated", + "value": "9 (STS), isolated worker model", + "stackSettings": { + "windowsRuntimeSettings": { + "runtimeVersion": "v9.0", + "isDefault": false, + "remoteDebuggingSupported": false, + "appInsightsSettings": { + "isSupported": true + }, + "gitHubActionSettings": { + "isSupported": true, + "supportedVersion": "9.0.x" + }, + "appSettingsDictionary": { + "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", + "WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED": "1" + }, + "siteConfigPropertiesDictionary": { + "use32BitWorkerProcess": false, + "netFrameworkVersion": "v9.0" + }, + "supportedFunctionsExtensionVersions": [ + "~4" + ], + "supportedFunctionsExtensionVersionsInfo": [ + { + "version": "~4", + "isDeprecated": false, + "isDefault": false + } + ], + "endOfLifeDate": "Tue May 12 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" + }, + "linuxRuntimeSettings": { + "runtimeVersion": "DOTNET-ISOLATED|9.0", + "isDefault": false, + "remoteDebuggingSupported": false, + "appInsightsSettings": { + "isSupported": true + }, + "gitHubActionSettings": { + "isSupported": true, + "supportedVersion": "9.0.x" + }, + "appSettingsDictionary": { + "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", + "WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED": "1" + }, + "siteConfigPropertiesDictionary": { + "use32BitWorkerProcess": false, + "linuxFxVersion": "DOTNET-ISOLATED|9.0" + }, + "supportedFunctionsExtensionVersions": [ + "~4" + ], + "supportedFunctionsExtensionVersionsInfo": [ + { + "version": "~4", + "isDeprecated": false, + "isDefault": false + } + ], + "endOfLifeDate": "Tue May 12 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" + } + } + } + ] + }, { "displayText": ".NET 8 Isolated", "value": "dotnet8isolated", @@ -277,7 +351,7 @@ "value": "8 (LTS), in-process model", "stackSettings": { "windowsRuntimeSettings": { - "isHidden": true, + "isHidden": false, "runtimeVersion": "v8.0", "remoteDebuggingSupported": false, "appInsightsSettings": { @@ -308,7 +382,7 @@ "endOfLifeDate": "Tue Nov 10 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { - "isHidden": true, + "isHidden": false, "runtimeVersion": "DOTNET|8.0", "remoteDebuggingSupported": false, "appInsightsSettings": { @@ -528,27 +602,27 @@ "preferredOs": "windows", "majorVersions": [ { - "displayText": "Node.js 20", - "value": "20", + "displayText": "Node.js 22", + "value": "22", "minorVersions": [ { - "displayText": "Node.js 20 LTS", - "value": "20 LTS", + "displayText": "Node.js 22", + "value": "22", "stackSettings": { "windowsRuntimeSettings": { - "runtimeVersion": "~20", - "isDefault": true, + "runtimeVersion": "~22", + "isPreview": true, "remoteDebuggingSupported": false, "appInsightsSettings": { "isSupported": true }, "gitHubActionSettings": { "isSupported": true, - "supportedVersion": "20.x" + "supportedVersion": "22.x" }, "appSettingsDictionary": { "FUNCTIONS_WORKER_RUNTIME": "node", - "WEBSITE_NODE_DEFAULT_VERSION": "~20" + "WEBSITE_NODE_DEFAULT_VERSION": "~22" }, "siteConfigPropertiesDictionary": { "use32BitWorkerProcess": true, @@ -564,10 +638,10 @@ "isDefault": true } ], - "endOfLifeDate": "Sat May 30 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Fri Apr 30 2027 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { - "runtimeVersion": "Node|20", + "runtimeVersion": "Node|22", "isDefault": true, "remoteDebuggingSupported": false, "appInsightsSettings": { @@ -575,14 +649,14 @@ }, "gitHubActionSettings": { "isSupported": true, - "supportedVersion": "20.x" + "supportedVersion": "22.x" }, "appSettingsDictionary": { "FUNCTIONS_WORKER_RUNTIME": "node" }, "siteConfigPropertiesDictionary": { "use32BitWorkerProcess": false, - "linuxFxVersion": "Node|20" + "linuxFxVersion": "Node|22" }, "supportedFunctionsExtensionVersions": [ "~4" @@ -594,33 +668,34 @@ "isDefault": true } ], - "endOfLifeDate": "Sat May 30 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Fri Apr 30 2027 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } ] }, { - "displayText": "Node.js 18", - "value": "18", + "displayText": "Node.js 20", + "value": "20", "minorVersions": [ { - "displayText": "Node.js 18 LTS", - "value": "18 LTS", + "displayText": "Node.js 20 LTS", + "value": "20 LTS", "stackSettings": { "windowsRuntimeSettings": { - "runtimeVersion": "~18", + "runtimeVersion": "~20", + "isDefault": true, "remoteDebuggingSupported": false, "appInsightsSettings": { "isSupported": true }, "gitHubActionSettings": { "isSupported": true, - "supportedVersion": "18.x" + "supportedVersion": "20.x" }, "appSettingsDictionary": { "FUNCTIONS_WORKER_RUNTIME": "node", - "WEBSITE_NODE_DEFAULT_VERSION": "~18" + "WEBSITE_NODE_DEFAULT_VERSION": "~20" }, "siteConfigPropertiesDictionary": { "use32BitWorkerProcess": true, @@ -636,24 +711,24 @@ "isDefault": true } ], - "endOfLifeDate": "Wed Apr 30 2025 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Thu Apr 30 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { - "runtimeVersion": "Node|18", + "runtimeVersion": "Node|20", "remoteDebuggingSupported": false, "appInsightsSettings": { "isSupported": true }, "gitHubActionSettings": { "isSupported": true, - "supportedVersion": "18.x" + "supportedVersion": "20.x" }, "appSettingsDictionary": { "FUNCTIONS_WORKER_RUNTIME": "node" }, "siteConfigPropertiesDictionary": { "use32BitWorkerProcess": false, - "linuxFxVersion": "Node|18" + "linuxFxVersion": "Node|20" }, "supportedFunctionsExtensionVersions": [ "~4" @@ -665,34 +740,33 @@ "isDefault": true } ], - "endOfLifeDate": "Wed Apr 30 2025 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Thu Apr 30 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } ] }, { - "displayText": "Node.js 16", - "value": "16", + "displayText": "Node.js 18", + "value": "18", "minorVersions": [ { - "displayText": "Node.js 16 LTS", - "value": "16 LTS", + "displayText": "Node.js 18 LTS", + "value": "18 LTS", "stackSettings": { "windowsRuntimeSettings": { - "runtimeVersion": "~16", - "isPreview": false, + "runtimeVersion": "~18", "remoteDebuggingSupported": false, "appInsightsSettings": { "isSupported": true }, "gitHubActionSettings": { "isSupported": true, - "supportedVersion": "16.x" + "supportedVersion": "18.x" }, "appSettingsDictionary": { "FUNCTIONS_WORKER_RUNTIME": "node", - "WEBSITE_NODE_DEFAULT_VERSION": "~16" + "WEBSITE_NODE_DEFAULT_VERSION": "~18" }, "siteConfigPropertiesDictionary": { "use32BitWorkerProcess": true, @@ -708,25 +782,24 @@ "isDefault": true } ], - "endOfLifeDate": "Sun Jun 30 2024 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Wed Apr 30 2025 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { - "runtimeVersion": "Node|16", - "isPreview": false, + "runtimeVersion": "Node|18", "remoteDebuggingSupported": false, "appInsightsSettings": { "isSupported": true }, "gitHubActionSettings": { "isSupported": true, - "supportedVersion": "16.x" + "supportedVersion": "18.x" }, "appSettingsDictionary": { "FUNCTIONS_WORKER_RUNTIME": "node" }, "siteConfigPropertiesDictionary": { "use32BitWorkerProcess": false, - "linuxFxVersion": "Node|16" + "linuxFxVersion": "Node|18" }, "supportedFunctionsExtensionVersions": [ "~4" @@ -738,191 +811,66 @@ "isDefault": true } ], - "endOfLifeDate": "Sun Jun 30 2024 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Wed Apr 30 2025 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } ] - }, + } + ] + } + }, + { + "id": null, + "name": "python", + "type": "Microsoft.Web/functionAppStacks?stackOsType=All", + "properties": { + "displayText": "Python", + "value": "python", + "preferredOs": "linux", + "majorVersions": [ { - "displayText": "Node.js 14", - "value": "14", + "displayText": "Python 3", + "value": "3", "minorVersions": [ { - "displayText": "Node.js 14 LTS", - "value": "14 LTS", + "displayText": "Python 3.12", + "value": "3.12", "stackSettings": { - "windowsRuntimeSettings": { - "runtimeVersion": "~14", - "remoteDebuggingSupported": false, - "appInsightsSettings": { - "isSupported": true - }, - "gitHubActionSettings": { - "isSupported": true, - "supportedVersion": "14.x" - }, - "appSettingsDictionary": { - "FUNCTIONS_WORKER_RUNTIME": "node", - "WEBSITE_NODE_DEFAULT_VERSION": "~14" - }, - "siteConfigPropertiesDictionary": { - "use32BitWorkerProcess": true, - "netFrameworkVersion": "v6.0" - }, - "supportedFunctionsExtensionVersions": [ - "~4", - "~3" - ], - "supportedFunctionsExtensionVersionsInfo": [ - { - "version": "~4", - "isDeprecated": false, - "isDefault": true - }, - { - "version": "~3", - "isDeprecated": true, - "isDefault": false - } - ], - "endOfLifeDate": "Sun Apr 30 2023 00:00:00 GMT+0000 (Coordinated Universal Time)" - }, "linuxRuntimeSettings": { - "runtimeVersion": "Node|14", + "runtimeVersion": "Python|3.12", "remoteDebuggingSupported": false, + "isPreview": false, + "isDefault": true, + "isHidden": false, "appInsightsSettings": { "isSupported": true }, "gitHubActionSettings": { "isSupported": true, - "supportedVersion": "14.x" + "supportedVersion": "3.12" }, "appSettingsDictionary": { - "FUNCTIONS_WORKER_RUNTIME": "node" + "FUNCTIONS_WORKER_RUNTIME": "python" }, "siteConfigPropertiesDictionary": { "use32BitWorkerProcess": false, - "linuxFxVersion": "Node|14" + "linuxFxVersion": "Python|3.12" }, "supportedFunctionsExtensionVersions": [ - "~4", - "~3" + "~4" ], "supportedFunctionsExtensionVersionsInfo": [ { "version": "~4", "isDeprecated": false, "isDefault": true - }, - { - "version": "~3", - "isDeprecated": true, - "isDefault": false - } - ], - "endOfLifeDate": "Sun Apr 30 2023 00:00:00 GMT+0000 (Coordinated Universal Time)" - } - } - } - ] - }, - { - "displayText": "Node.js 8", - "value": "8", - "minorVersions": [ - { - "displayText": "Node.js 8 LTS", - "value": "8 LTS", - "stackSettings": { - "windowsRuntimeSettings": { - "runtimeVersion": "~8", - "remoteDebuggingSupported": false, - "appInsightsSettings": { - "isSupported": true - }, - "gitHubActionSettings": { - "isSupported": true, - "supportedVersion": "8.x" - }, - "appSettingsDictionary": { - "FUNCTIONS_WORKER_RUNTIME": "node", - "WEBSITE_NODE_DEFAULT_VERSION": "~8" - }, - "siteConfigPropertiesDictionary": { - "use32BitWorkerProcess": true - }, - "supportedFunctionsExtensionVersions": [ - "~2" - ], - "supportedFunctionsExtensionVersionsInfo": [ - { - "version": "~2", - "isDeprecated": true, - "isDefault": true } ], - "endOfLifeDate": "Tue Dec 31 2019 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Tue Oct 31 2028 00:00:00 GMT+0000 (Coordinated Universal Time)" } } - } - ] - }, - { - "displayText": "Node.js 6", - "value": "6", - "minorVersions": [ - { - "displayText": "Node.js 6 LTS", - "value": "6 LTS", - "stackSettings": { - "windowsRuntimeSettings": { - "runtimeVersion": "~6", - "remoteDebuggingSupported": false, - "appInsightsSettings": { - "isSupported": true - }, - "gitHubActionSettings": { - "isSupported": false - }, - "appSettingsDictionary": { - "WEBSITE_NODE_DEFAULT_VERSION": "~6" - }, - "siteConfigPropertiesDictionary": { - "use32BitWorkerProcess": true - }, - "supportedFunctionsExtensionVersions": [ - "~1" - ], - "supportedFunctionsExtensionVersionsInfo": [ - { - "version": "~1", - "isDeprecated": true, - "isDefault": true - } - ], - "endOfLifeDate": "Tue Apr 30 2019 00:00:00 GMT+0000 (Coordinated Universal Time)" - } - } - } - ] - } - ] - } - }, - { - "id": null, - "name": "python", - "type": "Microsoft.Web/functionAppStacks?stackOsType=All", - "properties": { - "displayText": "Python", - "value": "python", - "preferredOs": "linux", - "majorVersions": [ - { - "displayText": "Python 3", - "value": "3", - "minorVersions": [ + }, { "displayText": "Python 3.11", "value": "3.11", @@ -1079,7 +1027,7 @@ "isDefault": false } ], - "endOfLifeDate": "Thu Oct 31 2024 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Mon Oct 07 2024 00:00:00 GMT+0000 (Coordinated Universal Time)" } } }, @@ -1126,7 +1074,7 @@ "isDefault": false } ], - "endOfLifeDate": "Fri Jun 30 2023 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Tue Jun 27 2023 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } @@ -1154,8 +1102,8 @@ "stackSettings": { "windowsRuntimeSettings": { "runtimeVersion": "21", - "isPreview": true, - "isHidden": true, + "isPreview": false, + "isHidden": false, "isAutoUpdate": true, "isDefault": false, "remoteDebuggingSupported": false, @@ -1184,11 +1132,11 @@ "isDefault": true } ], - "endOfLifeDate": "Mon Sep 01 2031 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Fri Sep 01 2028 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { "runtimeVersion": "Java|21", - "isPreview": true, + "isPreview": false, "isHidden": false, "isAutoUpdate": true, "isDefault": false, @@ -1217,7 +1165,7 @@ "isDefault": true } ], - "endOfLifeDate": "Mon Sep 01 2031 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Fri Sep 01 2028 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } @@ -1263,7 +1211,7 @@ "isDefault": true } ], - "endOfLifeDate": "Mon Sep 01 2031 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Wed Sep 01 2027 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { "runtimeVersion": "Java|17", @@ -1296,7 +1244,7 @@ "isDefault": true } ], - "endOfLifeDate": "Mon Sep 01 2031 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Wed Sep 01 2027 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } @@ -1345,7 +1293,7 @@ "isDefault": false } ], - "endOfLifeDate": "Tue Sep 01 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Wed Sep 01 2027 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { "runtimeVersion": "Java|11", @@ -1381,7 +1329,7 @@ "isDefault": false } ], - "endOfLifeDate": "Tue Sep 01 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Wed Sep 01 2027 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } @@ -1437,7 +1385,7 @@ "isDefault": false } ], - "endOfLifeDate": "Sat Mar 01 2025 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Mon Nov 30 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" }, "linuxRuntimeSettings": { "runtimeVersion": "Java|8", @@ -1474,7 +1422,7 @@ "isDefault": false } ], - "endOfLifeDate": "Sat Mar 01 2025 00:00:00 GMT+0000 (Coordinated Universal Time)" + "endOfLifeDate": "Mon Nov 30 2026 00:00:00 GMT+0000 (Coordinated Universal Time)" } } } @@ -1502,8 +1450,8 @@ "stackSettings": { "windowsRuntimeSettings": { "runtimeVersion": "7.4", - "isDefault": false, - "isPreview": true, + "isDefault": true, + "isPreview": false, "isHidden": false, "remoteDebuggingSupported": false, "appInsightsSettings": { @@ -1534,8 +1482,8 @@ }, "linuxRuntimeSettings": { "runtimeVersion": "PowerShell|7.4", - "isDefault": false, - "isPreview": true, + "isDefault": true, + "isPreview": false, "isHidden": false, "remoteDebuggingSupported": false, "appInsightsSettings": { @@ -1571,7 +1519,7 @@ "stackSettings": { "windowsRuntimeSettings": { "runtimeVersion": "7.2", - "isDefault": true, + "isDefault": false, "isPreview": false, "isHidden": false, "remoteDebuggingSupported": false, @@ -1603,7 +1551,7 @@ }, "linuxRuntimeSettings": { "runtimeVersion": "PowerShell|7.2", - "isDefault": true, + "isDefault": false, "isPreview": false, "isHidden": false, "remoteDebuggingSupported": false, diff --git a/src/Functions/Functions.Autorest/custom/HelperFunctions.ps1 b/src/Functions/Functions.Autorest/custom/HelperFunctions.ps1 index b12209cabf97..3e3b7a6f93b7 100644 --- a/src/Functions/Functions.Autorest/custom/HelperFunctions.ps1 +++ b/src/Functions/Functions.Autorest/custom/HelperFunctions.ps1 @@ -1033,35 +1033,15 @@ function GetStackDefinitionForRuntime # If runtime version is not provided, iterate through the list to find the default version (if available) if (($Runtime -ne 'Custom') -and (-not $RuntimeVersion)) { - # Try to get the default version - $defaultVersionFound = $false - $RuntimeVersion = $supportedRuntimes[$Runtime] | - ForEach-Object { if ($_.IsDefault -and ($_.SupportedFunctionsExtensionVersions -contains $functionsExtensionVersion)) { $_.Version } } - - if ($RuntimeVersion) + $versionFound = $false + $version = GetDefaultOrLatestRuntimeVersion -SupportedRuntimes $supportedRuntimes -Runtime $Runtime -FunctionsExtensionVersion $functionsExtensionVersion + if (-not [string]::IsNullOrWhiteSpace($version)) { - $defaultVersionFound = $true - Write-Debug "$DEBUG_PREFIX Runtime '$Runtime' has a default version '$RuntimeVersion'" - } - else - { - Write-Debug "$DEBUG_PREFIX Runtime '$Runtime' does not have a default version. Finding the latest version." - - # Iterate through the list to find the latest non preview version - $latestVersion = $supportedRuntimes[$Runtime] | - Sort-Object -Property Version -Descending | - Where-Object { $_.SupportedFunctionsExtensionVersions -contains $functionsExtensionVersion -and (-not $_.IsPreview) } | - Select-Object -First 1 -ExpandProperty Version - - if ($latestVersion) - { - # Set the runtime version to the latest version - $RuntimeVersion = $latestVersion - } + $RuntimeVersion = $version + $versionFound = $true } - # Error out if we could not find a default or latest version for the given runtime (except for 'Custom'), functions extension version, and os type - if ((-not $latestVersion) -and (-not $defaultVersionFound) -and ($Runtime -ne 'Custom')) + if (-not $versionFound -and ($Runtime -ne 'Custom')) { $errorMessage = "Runtime '$Runtime' in Functions version '$FunctionsVersion' on '$OSType' is not supported." ThrowRuntimeNotSupportedException -Message $errorMessage -ErrorId "RuntimeVersionNotSupported" @@ -1104,9 +1084,80 @@ function GetStackDefinitionForRuntime Write-Verbose "Runtime '$Runtime' version '$RuntimeVersion' is in Preview for '$OSType'." -Verbose } + if ($runtimeJsonDefinition.EndOfLifeDate) + { + $today = Get-Today + $sixMonthsFromToday = (Get-Today).AddMonths(6) + $endOfLifeDate = $runtimeJsonDefinition.EndOfLifeDate + $formattedEOLDate = ([DateTime]$endOfLifeDate).ToString("MMMM dd yyyy") + + $defaultRuntimeVersion = GetDefaultOrLatestRuntimeVersion -SupportedRuntimes $supportedRuntimes ` + -Runtime $Runtime ` + -FunctionsExtensionVersion $functionsExtensionVersion + + if ($endOfLifeDate -le $today) + { + $errorMsg = "Use $Runtime $defaultRuntimeVersion as $Runtime $RuntimeVersion has reached end-of-life " + $errorMsg += "on $formattedEOLDate and is no longer supported. Learn more: aka.ms/FunctionsStackUpgrade." + + $exception = [System.InvalidOperationException]::New($errorMsg) + ThrowTerminatingError -ErrorId "RuntimeVersionEndOfLife" ` + -ErrorMessage $errorMsg ` + -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` + -Exception $exception + } + elseif ($endOfLifeDate -lt $sixMonthsFromToday) + { + $warningMsg = "Use $Runtime $defaultRuntimeVersion as $Runtime $RuntimeVersion will reach end-of-life on $formattedEOLDate" + $warningMsg += " and will no longer be supported. Learn more: aka.ms/FunctionsStackUpgrade." + Write-Warning $warningMsg + } + } + return $runtimeJsonDefinition } +function GetDefaultOrLatestRuntimeVersion { + [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] + param + ( + [Parameter(Mandatory=$true)] + [Hashtable] + $SupportedRuntimes, + [Parameter(Mandatory=$true)] + [String] + $Runtime, + [Parameter(Mandatory=$true)] + [String] + $FunctionsExtensionVersion + ) + + $defaultVersion = $SupportedRuntimes[$Runtime] | + Where-Object { $_.IsDefault -and ($_.SupportedFunctionsExtensionVersions -contains $FunctionsExtensionVersion) } | + Select-Object -First 1 -ExpandProperty Version + + if ($defaultVersion) { + Write-Debug "$DEBUG_PREFIX Runtime '$Runtime' has a default version '$defaultVersion'" + return $defaultVersion + } + + Write-Debug "$DEBUG_PREFIX Runtime '$Runtime' does not have a default version. Finding the latest version." + + $latestVersion = $SupportedRuntimes[$Runtime] | + Sort-Object -Property Version -Descending | + Where-Object { $_.SupportedFunctionsExtensionVersions -contains $FunctionsExtensionVersion -and (-not $_.IsPreview) } | + Select-Object -First 1 -ExpandProperty Version + + if ($latestVersion) { + Write-Debug "$DEBUG_PREFIX Latest version for runtime '$Runtime' is '$latestVersion'" + } + else { + Write-Debug "$DEBUG_PREFIX No latest version found for runtime '$Runtime'" + } + + return $latestVersion +} + function ThrowRuntimeNotSupportedException { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] @@ -1709,6 +1760,7 @@ Class Runtime [bool]$IsDefault [string]$PreferredOs [hashtable]$AppInsightsSettings + [Nullable[datetime]]$EndOfLifeDate } function GetBuiltInFunctionAppStacksDefinition @@ -1938,6 +1990,12 @@ function ParseMinorVersion $runtime.SiteConfigPropertiesDictionary = GetDictionary -SettingsDictionary $RuntimeSettings.SiteConfigPropertiesDictionary $runtime.AppInsightsSettings = GetDictionary -SettingsDictionary $RuntimeSettings.AppInsightsSettings $runtime.SupportedFunctionsExtensionVersions = GetSupportedFunctionsExtensionVersion -SupportedFunctionsExtensionVersions $RuntimeSettings.SupportedFunctionsExtensionVersions + $runtime.EndOfLifeDate = $null + + if (![string]::IsNullOrWhiteSpace($RuntimeSettings.EndOfLifeDate)) + { + $runtime.EndOfLifeDate = ParseEndOfLifeDate -Runtime $runtimeName -DateString $RuntimeSettings.EndOfLifeDate + } foreach ($propertyName in @("isPreview", "isHidden", "isDefault")) { @@ -2386,3 +2444,45 @@ function GetManagedEnvironment return $managedEnv } + +function ParseEndOfLifeDate +{ + [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $Runtime, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $DateString + ) + + try + { + $dateTime = [DateTime]::ParseExact($DateString, "ddd MMM dd yyyy HH:mm:ss 'GMT'K '(Coordinated Universal Time)'", + [System.Globalization.CultureInfo]::InvariantCulture) + } + catch + { + $message = "Failed to parse the EndOfLifeDate '$DateString' for '$Runtime' runtime. Skipping..." + Write-Warning $message + } + + return $dateTime +} + +function Get-Today { + [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] + param () + + if ($env:FunctionsTestMode) + { + # Test hook to support running the tests in playback mode. + return [datetime]"2024-01-01" + } + return Get-Date +} diff --git a/src/Functions/Functions.Autorest/test/Get-Update-Remove-AzFunctionAppSetting.Tests.ps1 b/src/Functions/Functions.Autorest/test/Get-Update-Remove-AzFunctionAppSetting.Tests.ps1 index bd3efa5dfd25..c69fe2a10dd5 100644 --- a/src/Functions/Functions.Autorest/test/Get-Update-Remove-AzFunctionAppSetting.Tests.ps1 +++ b/src/Functions/Functions.Autorest/test/Get-Update-Remove-AzFunctionAppSetting.Tests.ps1 @@ -11,6 +11,8 @@ while(-not $mockingPath) { } . ($mockingPath | Select-Object -First 1).FullName +$env:FunctionsTestMode = $true + Describe 'Get-AzFunctionAppSetting, Update-AzFunctionAppSetting, and Remove-AzFunctionAppSetting E2E' { It "Validate Get-AzFunctionAppSetting, Update-AzFunctionAppSetting and Delete-AzFunctionAppSetting" { diff --git a/src/Functions/Functions.Autorest/test/New-AzFunctionApp.Tests.ps1 b/src/Functions/Functions.Autorest/test/New-AzFunctionApp.Tests.ps1 index e80cb941afc6..586fb3c391f8 100644 --- a/src/Functions/Functions.Autorest/test/New-AzFunctionApp.Tests.ps1 +++ b/src/Functions/Functions.Autorest/test/New-AzFunctionApp.Tests.ps1 @@ -11,6 +11,8 @@ while(-not $mockingPath) { } . ($mockingPath | Select-Object -First 1).FullName +$env:FunctionsTestMode = $true + Describe 'New-AzFunctionApp' { It 'CustomDockerImage' { diff --git a/src/Functions/Functions.Autorest/test/utils.ps1 b/src/Functions/Functions.Autorest/test/utils.ps1 index 1064f10bbdb1..7ce0cc6fb1e6 100644 --- a/src/Functions/Functions.Autorest/test/utils.ps1 +++ b/src/Functions/Functions.Autorest/test/utils.ps1 @@ -34,6 +34,11 @@ function Start-TestSleep { $env = @{} function setupEnv() { + # Set the test mode for the Az.Functions module + # This is requried to support playback mode (given that we need to have the same values in teh payload for each function app creation) + # Currently this flag is used to have a constant share name when creation an app + $env:FunctionsTestMode = $true + <# $localEnvFilePath = Join-Path $PSScriptRoot 'localEnv.json' if (Test-Path $localEnvFilePath) @@ -233,11 +238,6 @@ function setupEnv() { $newApplInsights = New-AzApplicationInsights -ResourceGroupName $env.resourceGroupNameWindowsPremium -Name $newApplInsightsName -Location $location $env.add('newApplInsights', $newApplInsights) | Out-Null - # Set the test mode for the Az.Functions module - # This is requried to support playback mode (given that we need to have the same values in teh payload for each function app creation) - # Currently this flag is used to have a constant share name when creation an app - $env:FunctionsTestMode = $true - $envFile = 'env.json' if ($TestMode -eq 'live') { $envFile = 'localEnv.json' diff --git a/src/Functions/Functions/ChangeLog.md b/src/Functions/Functions/ChangeLog.md index 539f43883913..3a9b5a53c44e 100644 --- a/src/Functions/Functions/ChangeLog.md +++ b/src/Functions/Functions/ChangeLog.md @@ -18,6 +18,9 @@ - Additional information about change #1 --> ## Upcoming Release +* Updated API client to latest commit for version 2023-12-01 +* Refreshed stack definitions +* Enforced runtime EOL policy for function app creation: block expired, warn if within 6 months ## Version 4.2.0 * Upgraded nuget package to signed package.