@@ -1843,11 +1843,7 @@ function ParseMinorVersion
18431843 (
18441844 [Parameter (Mandatory = $false )]
18451845 [System.String ]
1846- $RuntimeName ,
1847-
1848- [Parameter (Mandatory = $false )]
1849- [System.String ]
1850- $RuntimeVersion ,
1846+ $StackMinorVersion ,
18511847
18521848 [Parameter (Mandatory = $false )]
18531849 [System.String ]
@@ -1862,45 +1858,54 @@ function ParseMinorVersion
18621858 $RuntimeFullName ,
18631859
18641860 [Parameter (Mandatory = $false )]
1865- [Switch ]
1861+ [Bool ]
18661862 $StackIsLinux
18671863 )
18681864
18691865 # If this FunctionsVersion is not supported, skip it
18701866 if ($RuntimeSettings.supportedFunctionsExtensionVersions -notcontains " ~$DefaultFunctionsVersion " )
18711867 {
18721868 $supportedFunctionsExtensionVersions = $RuntimeSettings.supportedFunctionsExtensionVersions -join " , "
1873- Write-Debug " $DEBUG_PREFIX Minimium required Functions version '$DefaultFunctionsVersion ' is not supported. Current supported Functions versions: $supportedFunctionsExtensionVersions . Skipping..."
1869+ Write-Debug " $DEBUG_PREFIX Minimium required Functions version '$DefaultFunctionsVersion ' is not supported. Runtime supported Functions versions: $supportedFunctionsExtensionVersions . Skipping..."
18741870 return
18751871 }
18761872 else
18771873 {
18781874 Write-Debug " $DEBUG_PREFIX Minimium required Functions version '$DefaultFunctionsVersion ' is supported."
18791875 }
18801876
1881- if (-not $RuntimeName )
1882- {
1883- $RuntimeName = GetRuntimeName - AppSettingsDictionary $RuntimeSettings.AppSettingsDictionary
1884- }
1877+ $runtimeName = GetRuntimeName - AppSettingsDictionary $RuntimeSettings.AppSettingsDictionary
18851878
1886- if ($runtimeName -like " dotnet*" -or $runtimeName -like " node*" )
1879+ $version = $null
1880+ if ($RuntimeName -eq " Java" -and $RuntimeSettings.RuntimeVersion -eq " 1.8" )
18871881 {
1888- $RuntimeVersion = GetRuntimeVersion - Version $RuntimeVersion
1882+ # Java 8 is only supported in Windows. The display value is 8; however, the actual SiteConfig.JavaVersion is 1.8
1883+ $version = $StackMinorVersion
18891884 }
1890-
1891- # Some runtimes do not have a version like custom handler
1892- if (-not $runtimeVersion -and $RuntimeSettings.RuntimeVersion )
1885+ else
18931886 {
1894- $version = GetRuntimeVersion - Version $RuntimeSettings.RuntimeVersion - StackIsLinux $StackIsLinux.IsPresent
1895- $RuntimeVersion = $version
1887+ $version = $RuntimeSettings.RuntimeVersion
18961888 }
18971889
1890+ $runtimeVersion = GetRuntimeVersion - Version $version - StackIsLinux $StackIsLinux
1891+
18981892 # For Java function app, the version from the Stacks API is 8.0, 11.0, and 17.0. However, this is a breaking change which cannot be supported in the current release.
1899- # We will convert the version to 8, 11, and 17. This change will be reverted for the November 2023 breaking release.
1893+ # We will convert the version to 8, 11, and 17. This change will be reverted for the May 2024 breaking release.
19001894 if ($RuntimeName -eq " Java" )
19011895 {
1902- $RuntimeVersion = [int ]$RuntimeVersion
1903- Write-Debug " $DEBUG_PREFIX Runtime version for Java is modified to be compatible with the current release. Current version '$RuntimeVersion '"
1896+ $runtimeVersion = [int ]$runtimeVersion
1897+ Write-Debug " $DEBUG_PREFIX Runtime version for Java is modified to be compatible with the current release. Current version '$runtimeVersion '"
1898+ }
1899+
1900+ # For DotNet function app, the version from the Stacks API is 6.0. 7.0, and 8.0. However, this is a breaking change which cannot be supported in the current release.
1901+ # We will convert the version to 6, 7, and 8. This change will be reverted for the May 2024 breaking release.
1902+ if ($RuntimeName -like " DotNet*" )
1903+ {
1904+ if ($runtimeVersion.EndsWith (" .0" ))
1905+ {
1906+ $runtimeVersion = [int ]$runtimeVersion
1907+ }
1908+ Write-Debug " $DEBUG_PREFIX Runtime version for $runtimeName is modified to be compatible with the current release. Current version '$runtimeVersion '"
19041909 }
19051910
19061911 $runtime = [Runtime ]::new()
@@ -1926,10 +1931,10 @@ function ParseMinorVersion
19261931 return
19271932 }
19281933
1929- if ($RuntimeVersion -and ($runtimeName -ne " custom" ))
1934+ if ($runtimeVersion -and ($runtimeName -ne " custom" ))
19301935 {
1931- Write-Debug " $DEBUG_PREFIX Runtime version: $RuntimeVersion "
1932- $runtime.Version = $RuntimeVersion
1936+ Write-Debug " $DEBUG_PREFIX Runtime version: $runtimeVersion "
1937+ $runtime.Version = $runtimeVersion
19331938 }
19341939 else
19351940 {
@@ -1947,7 +1952,7 @@ function ParseMinorVersion
19471952 $runtime.PreferredOs = $PreferredOs
19481953 }
19491954
1950- $targetOs = if ($StackIsLinux.IsPresent ) { ' Linux' } else { ' Windows' }
1955+ $targetOs = if ($StackIsLinux ) { ' Linux' } else { ' Windows' }
19511956 Write-Debug " $DEBUG_PREFIX Runtime '$runtimeName ' for '$targetOs ' parsed successfully."
19521957
19531958 return $runtime
@@ -1959,23 +1964,28 @@ function GetRuntimeVersion
19591964 [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute ()]
19601965 param
19611966 (
1962- [Parameter (Mandatory = $true )]
1963- [ValidateNotNullOrEmpty ()]
1967+ [Parameter (Mandatory = $false )]
19641968 [System.String ]
19651969 $Version ,
19661970
19671971 [Parameter (Mandatory = $false )]
1968- [Switch ]
1972+ [Bool ]
19691973 $StackIsLinux
19701974 )
19711975
1972- if ($StackIsLinux.IsPresent )
1976+ if (-not $Version )
1977+ {
1978+ # Some runtimes do not have a version like custom handler
1979+ return
1980+ }
1981+
1982+ if ($StackIsLinux )
19731983 {
19741984 $Version = $Version.Split (' |' )[1 ]
19751985 }
19761986 else
19771987 {
1978- $valuesToReplace = @ (' STS ' , ' non- ' , ' LTS ' , ' Isolated ' , ' ( ' , ' ) ' , ' ~ ' , ' custom ' )
1988+ $valuesToReplace = @ (' v ' , ' ~ ' )
19791989 foreach ($value in $valuesToReplace )
19801990 {
19811991 if ($Version.Contains ($value ))
@@ -1986,8 +1996,7 @@ function GetRuntimeVersion
19861996 }
19871997
19881998 $Version = $Version.Trim ()
1989-
1990- return $Version
1999+ return $Version
19912000}
19922001
19932002function GetDictionary
@@ -2123,27 +2132,26 @@ function SetLinuxandWindowsSupportedRuntimes
21232132 {
21242133 $preferredOs = $stackDefinition.properties.preferredOs
21252134
2126- # runtime name is the $stackDefinition.Name
2127- $runtimeName = $stackDefinition.properties.value
2128- Write-Debug " $DEBUG_PREFIX Parsing runtime name: $runtimeName "
2135+ $stackName = $stackDefinition.properties.value
2136+ Write-Debug " $DEBUG_PREFIX Parsing stack name: $stackName "
21292137
21302138 foreach ($majorVersion in $stackDefinition.properties.majorVersions )
21312139 {
21322140 foreach ($minorVersion in $majorVersion.minorVersions )
21332141 {
21342142 $runtimeFullName = $minorVersion.DisplayText
2135- $runtimeVersion = $minorVersion.value
21362143 Write-Debug " $DEBUG_PREFIX runtime full name: $runtimeFullName "
2137- Write-Debug " $DEBUG_PREFIX runtime version: $runtimeVersion "
21382144
2145+ $stackMinorVersion = $minorVersion.value
2146+ Write-Debug " $DEBUG_PREFIX stack minor version: $stackMinorVersion "
21392147 $runtime = $null
21402148
21412149 if (ContainsProperty - Object $minorVersion.stackSettings - PropertyName " windowsRuntimeSettings" )
21422150 {
2143- $runtime = ParseMinorVersion - RuntimeVersion $runtimeVersion `
2144- - RuntimeSettings $minorVersion.stackSettings.windowsRuntimeSettings `
2151+ $runtime = ParseMinorVersion - RuntimeSettings $minorVersion.stackSettings.windowsRuntimeSettings `
21452152 - RuntimeFullName $runtimeFullName `
2146- - PreferredOs $preferredOs
2153+ - PreferredOs $preferredOs `
2154+ - StackMinorVersion $stackMinorVersion
21472155
21482156 if ($runtime )
21492157 {
@@ -2153,11 +2161,10 @@ function SetLinuxandWindowsSupportedRuntimes
21532161
21542162 if (ContainsProperty - Object $minorVersion.stackSettings - PropertyName " linuxRuntimeSettings" )
21552163 {
2156- $runtime = ParseMinorVersion - RuntimeVersion $runtimeVersion `
2157- - RuntimeSettings $minorVersion.stackSettings.linuxRuntimeSettings `
2164+ $runtime = ParseMinorVersion - RuntimeSettings $minorVersion.stackSettings.linuxRuntimeSettings `
21582165 - RuntimeFullName $runtimeFullName `
21592166 - PreferredOs $preferredOs `
2160- - StackIsLinux
2167+ - StackIsLinux $true
21612168
21622169 if ($runtime )
21632170 {
@@ -2168,44 +2175,60 @@ function SetLinuxandWindowsSupportedRuntimes
21682175 }
21692176 }
21702177}
2171- SetLinuxandWindowsSupportedRuntimes
21722178
2173- # New-AzFunction app ArgumentCompleter for the RuntimeVersion parameter
2174- # The values of RuntimeVersion depend on the selection of the Runtime parameter
2175- $GetRuntimeVersionCompleter = {
2176-
2177- param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
2179+ # This method pulls down the Functions stack definitions from the ARM API and builds a list of supported runtimes and runtime versions.
2180+ # This is used to build the tab completers for the New-AzFunctionApp cmdlet.
2181+ function RegisterFunctionsTabCompleters
2182+ {
2183+ [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute ()]
2184+ param ()
21782185
2179- if ($fakeBoundParameters .ContainsKey ( ' Runtime ' ) )
2186+ if ($env: FunctionsTabCompletersRegistered )
21802187 {
2181- # RuntimeVersions is defined in SetLinuxandWindowsSupportedRuntimes
2182- $AllRuntimeVersions [$fakeBoundParameters.Runtime ] | Where-Object {
2183- $_ -like " $wordToComplete *"
2184- } | ForEach-Object { [System.Management.Automation.CompletionResult ]::new($_ , $_ , ' ParameterValue' , $_ ) }
2188+ return
21852189 }
2186- }
21872190
2188- # New-AzFunction app ArgumentCompleter for the Runtime parameter
2189- $GetAllRuntimesCompleter = {
2191+ SetLinuxandWindowsSupportedRuntimes
21902192
2191- param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
2193+ # New-AzFunction app ArgumentCompleter for the RuntimeVersion parameter
2194+ # The values of RuntimeVersion depend on the selection of the Runtime parameter
2195+ $GetRuntimeVersionCompleter = {
21922196
2193- $runtimeValues = $AllRuntimeVersions .Keys | Sort-Object | ForEach-Object { $_ }
2197+ param ( $commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
21942198
2195- $runtimeValues | Where-Object { $_ -like " $wordToComplete *" }
2196- }
2199+ if ($fakeBoundParameters.ContainsKey (' Runtime' ))
2200+ {
2201+ # RuntimeVersions is defined in SetLinuxandWindowsSupportedRuntimes
2202+ $AllRuntimeVersions [$fakeBoundParameters.Runtime ] | Where-Object {
2203+ $_ -like " $wordToComplete *"
2204+ } | ForEach-Object { [System.Management.Automation.CompletionResult ]::new($_ , $_ , ' ParameterValue' , $_ ) }
2205+ }
2206+ }
21972207
2198- # New-AzFunction app ArgumentCompleter for the Runtime parameter
2199- $GetAllFunctionsVersionsCompleter = {
2208+ # New-AzFunction app ArgumentCompleter for the Runtime parameter
2209+ $GetAllRuntimesCompleter = {
22002210
2201- param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
2211+ param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
22022212
2203- $functionsVersions = $AllFunctionsExtensionVersions | Sort-Object | ForEach-Object { $_ }
2213+ $runtimeValues = $AllRuntimeVersions .Keys | Sort-Object | ForEach-Object { $_ }
22042214
2205- $functionsVersions | Where-Object { $_ -like " $wordToComplete *" }
2206- }
2215+ $runtimeValues | Where-Object { $_ -like " $wordToComplete *" }
2216+ }
2217+
2218+ # New-AzFunction app ArgumentCompleter for the Runtime parameter
2219+ $GetAllFunctionsVersionsCompleter = {
2220+
2221+ param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
22072222
2208- # Register tab completers
2209- Register-ArgumentCompleter - CommandName New-AzFunctionApp - ParameterName FunctionsVersion - ScriptBlock $GetAllFunctionsVersionsCompleter
2210- Register-ArgumentCompleter - CommandName New-AzFunctionApp - ParameterName Runtime - ScriptBlock $GetAllRuntimesCompleter
2211- Register-ArgumentCompleter - CommandName New-AzFunctionApp - ParameterName RuntimeVersion - ScriptBlock $GetRuntimeVersionCompleter
2223+ $functionsVersions = $AllFunctionsExtensionVersions | Sort-Object | ForEach-Object { $_ }
2224+
2225+ $functionsVersions | Where-Object { $_ -like " $wordToComplete *" }
2226+ }
2227+
2228+ # Register tab completers
2229+ Register-ArgumentCompleter - CommandName New-AzFunctionApp - ParameterName FunctionsVersion - ScriptBlock $GetAllFunctionsVersionsCompleter
2230+ Register-ArgumentCompleter - CommandName New-AzFunctionApp - ParameterName Runtime - ScriptBlock $GetAllRuntimesCompleter
2231+ Register-ArgumentCompleter - CommandName New-AzFunctionApp - ParameterName RuntimeVersion - ScriptBlock $GetRuntimeVersionCompleter
2232+
2233+ $env: FunctionsTabCompletersRegistered = $true
2234+ }
0 commit comments