@@ -1843,11 +1843,7 @@ function ParseMinorVersion
1843
1843
(
1844
1844
[Parameter (Mandatory = $false )]
1845
1845
[System.String ]
1846
- $RuntimeName ,
1847
-
1848
- [Parameter (Mandatory = $false )]
1849
- [System.String ]
1850
- $RuntimeVersion ,
1846
+ $StackMinorVersion ,
1851
1847
1852
1848
[Parameter (Mandatory = $false )]
1853
1849
[System.String ]
@@ -1862,45 +1858,54 @@ function ParseMinorVersion
1862
1858
$RuntimeFullName ,
1863
1859
1864
1860
[Parameter (Mandatory = $false )]
1865
- [Switch ]
1861
+ [Bool ]
1866
1862
$StackIsLinux
1867
1863
)
1868
1864
1869
1865
# If this FunctionsVersion is not supported, skip it
1870
1866
if ($RuntimeSettings.supportedFunctionsExtensionVersions -notcontains " ~$DefaultFunctionsVersion " )
1871
1867
{
1872
1868
$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..."
1874
1870
return
1875
1871
}
1876
1872
else
1877
1873
{
1878
1874
Write-Debug " $DEBUG_PREFIX Minimium required Functions version '$DefaultFunctionsVersion ' is supported."
1879
1875
}
1880
1876
1881
- if (-not $RuntimeName )
1882
- {
1883
- $RuntimeName = GetRuntimeName - AppSettingsDictionary $RuntimeSettings.AppSettingsDictionary
1884
- }
1877
+ $runtimeName = GetRuntimeName - AppSettingsDictionary $RuntimeSettings.AppSettingsDictionary
1885
1878
1886
- if ($runtimeName -like " dotnet*" -or $runtimeName -like " node*" )
1879
+ $version = $null
1880
+ if ($RuntimeName -eq " Java" -and $RuntimeSettings.RuntimeVersion -eq " 1.8" )
1887
1881
{
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
1889
1884
}
1890
-
1891
- # Some runtimes do not have a version like custom handler
1892
- if (-not $runtimeVersion -and $RuntimeSettings.RuntimeVersion )
1885
+ else
1893
1886
{
1894
- $version = GetRuntimeVersion - Version $RuntimeSettings.RuntimeVersion - StackIsLinux $StackIsLinux.IsPresent
1895
- $RuntimeVersion = $version
1887
+ $version = $RuntimeSettings.RuntimeVersion
1896
1888
}
1897
1889
1890
+ $runtimeVersion = GetRuntimeVersion - Version $version - StackIsLinux $StackIsLinux
1891
+
1898
1892
# 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.
1900
1894
if ($RuntimeName -eq " Java" )
1901
1895
{
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 '"
1904
1909
}
1905
1910
1906
1911
$runtime = [Runtime ]::new()
@@ -1926,10 +1931,10 @@ function ParseMinorVersion
1926
1931
return
1927
1932
}
1928
1933
1929
- if ($RuntimeVersion -and ($runtimeName -ne " custom" ))
1934
+ if ($runtimeVersion -and ($runtimeName -ne " custom" ))
1930
1935
{
1931
- Write-Debug " $DEBUG_PREFIX Runtime version: $RuntimeVersion "
1932
- $runtime.Version = $RuntimeVersion
1936
+ Write-Debug " $DEBUG_PREFIX Runtime version: $runtimeVersion "
1937
+ $runtime.Version = $runtimeVersion
1933
1938
}
1934
1939
else
1935
1940
{
@@ -1947,7 +1952,7 @@ function ParseMinorVersion
1947
1952
$runtime.PreferredOs = $PreferredOs
1948
1953
}
1949
1954
1950
- $targetOs = if ($StackIsLinux.IsPresent ) { ' Linux' } else { ' Windows' }
1955
+ $targetOs = if ($StackIsLinux ) { ' Linux' } else { ' Windows' }
1951
1956
Write-Debug " $DEBUG_PREFIX Runtime '$runtimeName ' for '$targetOs ' parsed successfully."
1952
1957
1953
1958
return $runtime
@@ -1959,23 +1964,28 @@ function GetRuntimeVersion
1959
1964
[Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute ()]
1960
1965
param
1961
1966
(
1962
- [Parameter (Mandatory = $true )]
1963
- [ValidateNotNullOrEmpty ()]
1967
+ [Parameter (Mandatory = $false )]
1964
1968
[System.String ]
1965
1969
$Version ,
1966
1970
1967
1971
[Parameter (Mandatory = $false )]
1968
- [Switch ]
1972
+ [Bool ]
1969
1973
$StackIsLinux
1970
1974
)
1971
1975
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 )
1973
1983
{
1974
1984
$Version = $Version.Split (' |' )[1 ]
1975
1985
}
1976
1986
else
1977
1987
{
1978
- $valuesToReplace = @ (' STS ' , ' non- ' , ' LTS ' , ' Isolated ' , ' ( ' , ' ) ' , ' ~ ' , ' custom ' )
1988
+ $valuesToReplace = @ (' v ' , ' ~ ' )
1979
1989
foreach ($value in $valuesToReplace )
1980
1990
{
1981
1991
if ($Version.Contains ($value ))
@@ -1986,8 +1996,7 @@ function GetRuntimeVersion
1986
1996
}
1987
1997
1988
1998
$Version = $Version.Trim ()
1989
-
1990
- return $Version
1999
+ return $Version
1991
2000
}
1992
2001
1993
2002
function GetDictionary
@@ -2123,27 +2132,26 @@ function SetLinuxandWindowsSupportedRuntimes
2123
2132
{
2124
2133
$preferredOs = $stackDefinition.properties.preferredOs
2125
2134
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 "
2129
2137
2130
2138
foreach ($majorVersion in $stackDefinition.properties.majorVersions )
2131
2139
{
2132
2140
foreach ($minorVersion in $majorVersion.minorVersions )
2133
2141
{
2134
2142
$runtimeFullName = $minorVersion.DisplayText
2135
- $runtimeVersion = $minorVersion.value
2136
2143
Write-Debug " $DEBUG_PREFIX runtime full name: $runtimeFullName "
2137
- Write-Debug " $DEBUG_PREFIX runtime version: $runtimeVersion "
2138
2144
2145
+ $stackMinorVersion = $minorVersion.value
2146
+ Write-Debug " $DEBUG_PREFIX stack minor version: $stackMinorVersion "
2139
2147
$runtime = $null
2140
2148
2141
2149
if (ContainsProperty - Object $minorVersion.stackSettings - PropertyName " windowsRuntimeSettings" )
2142
2150
{
2143
- $runtime = ParseMinorVersion - RuntimeVersion $runtimeVersion `
2144
- - RuntimeSettings $minorVersion.stackSettings.windowsRuntimeSettings `
2151
+ $runtime = ParseMinorVersion - RuntimeSettings $minorVersion.stackSettings.windowsRuntimeSettings `
2145
2152
- RuntimeFullName $runtimeFullName `
2146
- - PreferredOs $preferredOs
2153
+ - PreferredOs $preferredOs `
2154
+ - StackMinorVersion $stackMinorVersion
2147
2155
2148
2156
if ($runtime )
2149
2157
{
@@ -2153,11 +2161,10 @@ function SetLinuxandWindowsSupportedRuntimes
2153
2161
2154
2162
if (ContainsProperty - Object $minorVersion.stackSettings - PropertyName " linuxRuntimeSettings" )
2155
2163
{
2156
- $runtime = ParseMinorVersion - RuntimeVersion $runtimeVersion `
2157
- - RuntimeSettings $minorVersion.stackSettings.linuxRuntimeSettings `
2164
+ $runtime = ParseMinorVersion - RuntimeSettings $minorVersion.stackSettings.linuxRuntimeSettings `
2158
2165
- RuntimeFullName $runtimeFullName `
2159
2166
- PreferredOs $preferredOs `
2160
- - StackIsLinux
2167
+ - StackIsLinux $true
2161
2168
2162
2169
if ($runtime )
2163
2170
{
@@ -2168,44 +2175,60 @@ function SetLinuxandWindowsSupportedRuntimes
2168
2175
}
2169
2176
}
2170
2177
}
2171
- SetLinuxandWindowsSupportedRuntimes
2172
2178
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 ()
2178
2185
2179
- if ($fakeBoundParameters .ContainsKey ( ' Runtime ' ) )
2186
+ if ($env: FunctionsTabCompletersRegistered )
2180
2187
{
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
2185
2189
}
2186
- }
2187
2190
2188
- # New-AzFunction app ArgumentCompleter for the Runtime parameter
2189
- $GetAllRuntimesCompleter = {
2191
+ SetLinuxandWindowsSupportedRuntimes
2190
2192
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 = {
2192
2196
2193
- $runtimeValues = $AllRuntimeVersions .Keys | Sort-Object | ForEach-Object { $_ }
2197
+ param ( $commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
2194
2198
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
+ }
2197
2207
2198
- # New-AzFunction app ArgumentCompleter for the Runtime parameter
2199
- $GetAllFunctionsVersionsCompleter = {
2208
+ # New-AzFunction app ArgumentCompleter for the Runtime parameter
2209
+ $GetAllRuntimesCompleter = {
2200
2210
2201
- param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
2211
+ param ($commandName , $parameterName , $wordToComplete , $commandAst , $fakeBoundParameters )
2202
2212
2203
- $functionsVersions = $AllFunctionsExtensionVersions | Sort-Object | ForEach-Object { $_ }
2213
+ $runtimeValues = $AllRuntimeVersions .Keys | Sort-Object | ForEach-Object { $_ }
2204
2214
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 )
2207
2222
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