Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Functions/Az.Functions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For information on Azure Functions, please visit the following: https://docs.mic
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.Functions.private.dll'
FormatsToProcess = './Az.Functions.format.ps1xml', './custom/Functions.format.ps1xml'
TypesToProcess = './custom/Functions.types.ps1xml'
TypesToProcess = './custom/Functions.types.ps1xml'
ScriptsToProcess = './custom/HelperFunctions.ps1'
FunctionsToExport = 'Get-AzFunctionApp', 'Get-AzFunctionAppAvailableLocation', 'Get-AzFunctionAppPlan', 'Get-AzFunctionAppSetting', 'New-AzFunctionApp', 'New-AzFunctionAppPlan', 'Remove-AzFunctionApp', 'Remove-AzFunctionAppPlan', 'Remove-AzFunctionAppSetting', 'Restart-AzFunctionApp', 'Start-AzFunctionApp', 'Stop-AzFunctionApp', 'Update-AzFunctionApp', 'Update-AzFunctionAppPlan', 'Update-AzFunctionAppSetting'
PrivateData = @{
Expand Down
49 changes: 34 additions & 15 deletions src/Functions/custom/FunctionsStack/LinuxFunctionsStacks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
"dependency": null,
"majorVersions": [
{
"displayVersion": "",
"displayVersion": "3.1",
"supportedFunctionsExtensionVersions": [
"1",
"2",
"3"
"~3"
],
"runtimeVersion": null,
"runtimeVersion": "dotnet|3.1",
"isDefault": false,
"minorVersions": [],
"applicationInsights": true,
"appSettingsDictionary": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"linuxFxVersion": "dotnet|3.1"
},
"siteConfigPropertiesDictionary": {
"Use32BitWorkerProcess": false
Expand All @@ -48,7 +47,7 @@
"displayVersion": "12",
"runtimeVersion": "Node|12",
"supportedFunctionsExtensionVersions": [
"3"
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand All @@ -68,8 +67,8 @@
"displayVersion": "10",
"runtimeVersion": "Node|10",
"supportedFunctionsExtensionVersions": [
"2",
"3"
"~2",
"~3"
],
"isDefault": false,
"minorVersions": [],
Expand Down Expand Up @@ -103,8 +102,8 @@
"displayVersion": "3.6",
"runtimeVersion": "Python|3.6",
"supportedFunctionsExtensionVersions": [
"2",
"3"
"~2",
"~3"
],
"isDefault": false,
"minorVersions": [],
Expand All @@ -124,8 +123,8 @@
"displayVersion": "3.7",
"runtimeVersion": "Python|3.7",
"supportedFunctionsExtensionVersions": [
"2",
"3"
"~2",
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand All @@ -145,7 +144,7 @@
"displayVersion": "3.8",
"runtimeVersion": "Python|3.8",
"supportedFunctionsExtensionVersions": [
"3"
"~3"
],
"isDefault": false,
"minorVersions": [],
Expand Down Expand Up @@ -179,7 +178,7 @@
"displayVersion": "8",
"runtimeVersion": "Java|8",
"supportedFunctionsExtensionVersions": [
"3"
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand All @@ -194,6 +193,26 @@
"isPreview": false,
"isDeprecated": false,
"isHidden": false
},
{
"displayVersion": "11",
"runtimeVersion": "Java|11",
"supportedFunctionsExtensionVersions": [
"~3"
],
"isDefault": true,
"minorVersions": [],
"applicationInsights": true,
"appSettingsDictionary": {
"FUNCTIONS_WORKER_RUNTIME": "java"
},
"siteConfigPropertiesDictionary": {
"Use32BitWorkerProcess": false,
"linuxFxVersion": "Java|11"
},
"isPreview": false,
"isDeprecated": false,
"isHidden": false
}
],
"frameworks": [],
Expand Down
66 changes: 31 additions & 35 deletions src/Functions/custom/FunctionsStack/WindowsFunctionsStacks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
"dependency": null,
"majorVersions": [
{
"displayVersion": "",
"displayVersion": "3.1",
"runtimeVersion": null,
"supportedFunctionsExtensionVersions": [
"1",
"2",
"3"
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand Down Expand Up @@ -46,7 +44,7 @@
"displayVersion": "12",
"runtimeVersion": "~12",
"supportedFunctionsExtensionVersions": [
"3"
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand All @@ -64,8 +62,8 @@
"displayVersion": "10",
"runtimeVersion": "~10",
"supportedFunctionsExtensionVersions": [
"2",
"3"
"~2",
"~3"
],
"isDefault": false,
"minorVersions": [],
Expand All @@ -83,8 +81,8 @@
"displayVersion": "8",
"runtimeVersion": "~8",
"supportedFunctionsExtensionVersions": [
"1",
"2"
"~1",
"~2"
],
"isDefault": false,
"minorVersions": [],
Expand All @@ -97,25 +95,6 @@
"isPreview": false,
"isDeprecated": false,
"isHidden": false
},
{
"displayVersion": "6",
"runtimeVersion": "~6",
"supportedFunctionsExtensionVersions": [
"1",
"2"
],
"isDefault": false,
"minorVersions": [],
"applicationInsights": true,
"appSettingsDictionary": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"WEBSITE_NODE_DEFAULT_VERSION": "~6"
},
"siteConfigPropertiesDictionary": {},
"isPreview": false,
"isDeprecated": false,
"isHidden": false
}
],
"frameworks": [],
Expand All @@ -135,8 +114,25 @@
"displayVersion": "8",
"runtimeVersion": "1.8",
"supportedFunctionsExtensionVersions": [
"2",
"3"
"~2",
"~3"
],
"isDefault": true,
"minorVersions": [],
"applicationInsights": true,
"appSettingsDictionary": {
"FUNCTIONS_WORKER_RUNTIME": "java"
},
"siteConfigPropertiesDictionary": {},
"isPreview": false,
"isDeprecated": false,
"isHidden": false
},
{
"displayVersion": "11",
"runtimeVersion": "11",
"supportedFunctionsExtensionVersions": [
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand All @@ -160,15 +156,15 @@
"type": "Microsoft.Web/availableStacks?osTypeSelected=WindowsFunctions",
"properties": {
"name": "powershell",
"display": "Powershell Core",
"display": "PowerShell Core",
"dependency": null,
"majorVersions": [
{
"displayVersion": "6.2",
"runtimeVersion": "~6",
"supportedFunctionsExtensionVersions": [
"2",
"3"
"~2",
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand All @@ -184,10 +180,10 @@
"isHidden": false
},
{
"displayVersion": "7.0",
"displayVersion": "7.0",
"runtimeVersion": "~7",
"supportedFunctionsExtensionVersions": [
"3"
"~3"
],
"isDefault": true,
"minorVersions": [],
Expand Down
61 changes: 51 additions & 10 deletions src/Functions/custom/HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ $constants["RuntimeToDefaultOSType"] = @{
'Python' = 'Linux'
}

# This are use for tab completion for the RuntimeVersion parameter in New-AzFunctionApp
# These are used for tab completion for the RuntimeVersion parameter in New-AzFunctionApp.
$constants["RuntimeVersions"] = @{
'DotNet'= @(2, 3)
'Node' = @(8, 10, 12)
'Java' = @(8)
'PowerShell' = @(6.2)
'Python' = @(3.6, 3.7)
'DotNet'= @('2', '3')
'Node' = @('8', '10', '12')
'Java' = @('8', '11')
'PowerShell' = @('6.2', '7.0')
'Python' = @('3.6', '3.7', '3.8')
}

$constants["ReservedFunctionAppSettingNames"] = @(
Expand Down Expand Up @@ -223,6 +223,17 @@ function GetConnectionString

$resourceGroupName = ($storageAccountInfo.Id -split "/")[4]
$keys = Az.Functions.internal\Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountInfo.Name @PSBoundParameters -ErrorAction SilentlyContinue

if (-not $keys)
{
$errorMessage = "Failed to get key for storage account '$StorageAccountName'."
$exception = [System.InvalidOperationException]::New($errorMessage)
ThrowTerminatingError -ErrorId "FailedToGetStorageAccountKey" `
-ErrorMessage $errorMessage `
-ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) `
-Exception $exception
}

if ([string]::IsNullOrEmpty($keys[0].Value))
{
$errorMessage = "Storage account '$StorageAccountName' has no key value."
Expand Down Expand Up @@ -1013,7 +1024,9 @@ function ValidateRuntimeAndRuntimeVersion
{
if ($majorVersion.DisplayVersion -eq $RuntimeVersion)
{
if ($majorVersion.SupportedFunctionsExtensionVersions -contains $FunctionsVersion)
# SupportedFunctionsExtensionVersions[0] is of the form '~int'
# Add '~' to the begining of FunctionsVersion
if ($majorVersion.SupportedFunctionsExtensionVersions -contains "~$FunctionsVersion")
{
$runtimeVersionIsSupported = $true
break
Expand Down Expand Up @@ -1518,13 +1531,15 @@ function NewIdentityUserAssignedIdentity
# Set Linux and Windows supported runtimes
Class Runtime {
[string]$Name
[Object[]]$MajorVersions
[MajorVersion[]]$MajorVersions
}

Class MajorVersion {
[string]$DisplayVersion
[string]$RuntimeVersion
[string[]]$SupportedFunctionsExtensionVersions
[hashtable]$AppSettingsDictionary
[hashtable]$SiteConfigPropertiesDictionary
}

$LinuxRuntimes = @{}
Expand Down Expand Up @@ -1552,12 +1567,38 @@ function SetLinuxandWindowsSupportedRuntimes
{
$majorVersion = [MajorVersion]::new()

$majorVersion.RuntimeVersion = $version.RuntimeVersion
$majorVersion.SupportedFunctionsExtensionVersions = $version.supportedFunctionsExtensionVersions

if ($version.displayVersion)
{
$majorVersion.DisplayVersion = $version.displayVersion
}
$majorVersion.RuntimeVersion = $version.RuntimeVersion
$majorVersion.SupportedFunctionsExtensionVersions = $version.supportedFunctionsExtensionVersions

if ($version.appSettingsDictionary)
{
$appSettings = @{}

foreach ($property in $version.appSettingsDictionary.PSObject.Properties)
{
$appSettings.Add($property.Name, $property.Value)
}

$majorVersion.appSettingsDictionary = $appSettings
}

if ($version.appSettingsDictionary)
{
$siteConfigProperties = @{}

foreach ($property in $version.siteConfigPropertiesDictionary.PSObject.Properties)
{
$siteConfigProperties.Add($property.Name, $property.Value)
}

$majorVersion.SiteConfigPropertiesDictionary = $siteConfigProperties
}

$runtime.MajorVersions += $majorVersion
}

Expand Down
19 changes: 12 additions & 7 deletions src/Functions/custom/New-AzFunctionApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,6 @@ function New-AzFunctionApp {

$runtimeWorker = $Runtime.ToLower()
$appSettings.Add((NewAppSetting -Name 'FUNCTIONS_WORKER_RUNTIME' -Value "$runtimeWorker"))

# Set Java version
if ($Runtime -eq "Java")
{
$JavaVersion = GetWorkerVersion -FunctionsVersion $FunctionsVersion -Runtime $Runtime -RuntimeVersion $RuntimeVersion -OSType $OSType
$siteCofig.JavaVersion = "$JavaVersion"
}
}

$servicePlan = $null
Expand Down Expand Up @@ -364,6 +357,18 @@ function New-AzFunctionApp {
# Set default Node version
$defaultNodeVersion = GetFunctionAppDefaultNodeVersion -FunctionsVersion $FunctionsVersion -Runtime $Runtime -RuntimeVersion $RuntimeVersion
$appSettings.Add((NewAppSetting -Name 'WEBSITE_NODE_DEFAULT_VERSION' -Value $defaultNodeVersion))

# Set version for Java or PowerShell function apps
if ($Runtime -eq "Java")
{
$JavaVersion = GetWorkerVersion -FunctionsVersion $FunctionsVersion -Runtime $Runtime -RuntimeVersion $RuntimeVersion -OSType $OSType
$siteCofig.JavaVersion = "$JavaVersion"
}
elseif ($Runtime -eq "PowerShell")
{
$PowerShellWorkerVersion = GetWorkerVersion -FunctionsVersion $FunctionsVersion -Runtime $Runtime -RuntimeVersion $RuntimeVersion -OSType $OSType
$siteCofig.PowerShellVersion = "$PowerShellWorkerVersion"
}
}

# Validate storage account and get connection string
Expand Down
Loading