Functions.Autorest/custom/HelperFunctions.ps1
# Load Az.Functions module constants $constants = @{} $constants["AllowedStorageTypes"] = @('Standard_GRS', 'Standard_RAGRS', 'Standard_LRS', 'Standard_ZRS', 'Premium_LRS', 'Standard_GZRS') $constants["RequiredStorageEndpoints"] = @('PrimaryEndpointFile', 'PrimaryEndpointQueue', 'PrimaryEndpointTable') $constants["DefaultFunctionsVersion"] = '4' $constants["RuntimeToFormattedName"] = @{ 'dotnet' = 'DotNet' 'dotnet-isolated' = 'DotNet-Isolated' 'custom' = 'Custom' 'node' = 'Node' 'python' = 'Python' 'java' = 'Java' 'powershell' = 'PowerShell' } $constants["RuntimeToDefaultOSType"] = @{ 'DotNet'= 'Windows' 'DotNet-Isolated' = 'Windows' 'Custom' = 'Windows' 'Node' = 'Windows' 'Java' = 'Windows' 'PowerShell' = 'Windows' 'Python' = 'Linux' } $constants["ReservedFunctionAppSettingNames"] = @( 'FUNCTIONS_WORKER_RUNTIME' 'DOCKER_CUSTOM_IMAGE_NAME' 'FUNCTION_APP_EDIT_MODE' 'WEBSITES_ENABLE_APP_SERVICE_STORAGE' 'DOCKER_REGISTRY_SERVER_URL' 'DOCKER_REGISTRY_SERVER_USERNAME' 'DOCKER_REGISTRY_SERVER_PASSWORD' 'WEBSITES_ENABLE_APP_SERVICE_STORAGE' 'WEBSITE_NODE_DEFAULT_VERSION' 'AzureWebJobsStorage' 'AzureWebJobsDashboard' 'FUNCTIONS_EXTENSION_VERSION' 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING' 'WEBSITE_CONTENTSHARE' 'APPINSIGHTS_INSTRUMENTATIONKEY' ) $constants["SetDefaultValueParameterWarningMessage"] = "This default value is subject to change over time. Please set this value explicitly to ensure the behavior is not accidentally impacted by future changes." $constants["DEBUG_PREFIX"] = '[Stacks API] - ' foreach ($variableName in $constants.Keys) { if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue)) { Set-Variable $variableName -value $constants[$variableName] -option ReadOnly } } # These are used to hold the types for the tab completers $RuntimeToVersionLinux = @{} $RuntimeToVersionWindows = @{} $AllRuntimeVersions = @{} $AllFunctionsExtensionVersions = New-Object System.Collections.Generic.List[[String]] function GetConnectionString { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $StorageAccountName, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("StorageAccountName")) { $PSBoundParameters.Remove("StorageAccountName") | Out-Null } $storageAccountInfo = GetStorageAccount -Name $StorageAccountName @PSBoundParameters if (-not $storageAccountInfo) { $errorMessage = "Storage account '$StorageAccountName' does not exist." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "StorageAccountNotFound" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } if ($storageAccountInfo.ProvisioningState -ne "Succeeded") { $errorMessage = "Storage account '$StorageAccountName' is not ready. Please run 'Get-AzStorageAccount' and ensure that the ProvisioningState is 'Succeeded'" $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "StorageAccountNotFound" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } $skuName = $storageAccountInfo.SkuName if (-not ($AllowedStorageTypes -contains $skuName)) { $storageOptions = $AllowedStorageTypes -join ", " $errorMessage = "Storage type '$skuName' is not allowed'. Currently supported storage options: $storageOptions" $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "StorageTypeNotSupported" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } foreach ($endpoint in $RequiredStorageEndpoints) { if ([string]::IsNullOrEmpty($storageAccountInfo.$endpoint)) { $errorMessage = "Storage account '$StorageAccountName' has no '$endpoint' endpoint. It must have table, queue, and blob endpoints all enabled." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "StorageAccountRequiredEndpointNotAvailable" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } } $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." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "StorageAccountHasNoKeyValue" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } $suffix = GetEndpointSuffix $accountKey = $keys[0].Value $connectionString = "DefaultEndpointsProtocol=https;AccountName=$StorageAccountName;AccountKey=$accountKey" + $suffix return $connectionString } function GetEndpointSuffix { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param() $environmentName = (Get-AzContext).Environment.Name switch ($environmentName) { "AzureUSGovernment" { ';EndpointSuffix=core.usgovcloudapi.net' } "AzureChinaCloud" { ';EndpointSuffix=core.chinacloudapi.cn' } "AzureCloud" { ';EndpointSuffix=core.windows.net' } default { '' } } } function NewAppSetting { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Name, [Parameter(Mandatory=$false)] [System.String] $Value ) $setting = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.Functions.Models.Api20190801.NameValuePair $setting.Name = $Name $setting.Value = $Value return $setting } function GetServicePlan { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Name, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("Name")) { $PSBoundParameters.Remove("Name") | Out-Null } $plans = @(Az.Functions\Get-AzFunctionAppPlan @PSBoundParameters) foreach ($plan in $plans) { if ($plan.Name -eq $Name) { return $plan } } # The plan name was not found, error out $errorMessage = "Service plan '$Name' does not exist." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "ServicePlanDoesNotExist" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } function GetStorageAccount { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Name, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("Name")) { $PSBoundParameters.Remove("Name") | Out-Null } $storageAccounts = @(Az.Functions.internal\Get-AzStorageAccount @PSBoundParameters -ErrorAction SilentlyContinue) foreach ($account in $storageAccounts) { if ($account.Name -eq $Name) { return $account } } } function GetApplicationInsightsProject { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Name, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("Name")) { $PSBoundParameters.Remove("Name") | Out-Null } $projects = @(Az.Functions.internal\Get-AzAppInsights @PSBoundParameters) foreach ($project in $projects) { if ($project.Name -eq $Name) { return $project } } } function CreateApplicationInsightsProject { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $ResourceName, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $ResourceGroupName, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Location, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) $paramsToRemove = @( "ResourceGroupName", "ResourceName", "Location" ) foreach ($paramName in $paramsToRemove) { if ($PSBoundParameters.ContainsKey($paramName)) { $PSBoundParameters.Remove($paramName) | Out-Null } } # Create a new ApplicationInsights $maxNumberOfTries = 3 $tries = 1 while ($true) { try { $newAppInsightsProject = Az.Functions.internal\New-AzAppInsights -ResourceGroupName $ResourceGroupName ` -ResourceName $ResourceName ` -Location $Location ` -Kind web ` -RequestSource "AzurePowerShell" ` -ErrorAction Stop ` @PSBoundParameters if ($newAppInsightsProject) { return $newAppInsightsProject } } catch { # Ignore the failure and continue } if ($tries -ge $maxNumberOfTries) { break } # Wait for 2^(tries-1) seconds between retries. In this case, it would be 1, 2, and 4 seconds, respectively. $waitInSeconds = [Math]::Pow(2, $tries - 1) Start-Sleep -Seconds $waitInSeconds $tries++ } } function ConvertWebAppApplicationSettingToHashtable { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object] $ApplicationSetting, [System.Management.Automation.SwitchParameter] $ShowAllAppSettings, [System.Management.Automation.SwitchParameter] $RedactAppSettings, [System.Management.Automation.SwitchParameter] $ShowOnlySpecificAppSettings, [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [String[]] $AppSettingsToShow ) if ($RedactAppSettings.IsPresent) { Write-Warning "App settings have been redacted. Use the Get-AzFunctionAppSetting cmdlet to view them." } # Create a key value pair to hold the function app settings $applicationSettings = @{} foreach ($keyName in $ApplicationSetting.Property.Keys) { if($ShowAllAppSettings.IsPresent) { $applicationSettings[$keyName] = $ApplicationSetting.Property[$keyName] } elseif ($RedactAppSettings.IsPresent) { # When RedactAppSettings is present, all app settings are set to null $applicationSettings[$keyName] = $null } elseif($ShowOnlySpecificAppSettings.IsPresent) { # When ShowOnlySpecificAppSettings is present, only show the app settings in this list AppSettingsToShow if ($AppSettingsToShow.Contains($keyName)) { $applicationSettings[$keyName] = $ApplicationSetting.Property[$keyName] } } } return $applicationSettings } function GetRuntime { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object] $Settings ) $appSettings = ConvertWebAppApplicationSettingToHashtable -ApplicationSetting $Settings -ShowAllAppSettings $runtimeName = $appSettings["FUNCTIONS_WORKER_RUNTIME"] $runtime = "" if (($null -ne $runtimeName) -and ($RuntimeToFormattedName.ContainsKey($runtimeName))) { $runtime = $RuntimeToFormattedName[$runtimeName] } elseif ($appSettings.ContainsKey("DOCKER_CUSTOM_IMAGE_NAME")) { $runtime = "Custom Image" } return $runtime } function AddFunctionAppSettings { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Object] $App, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("App")) { $PSBoundParameters.Remove("App") | Out-Null } $App.AppServicePlan = ($App.ServerFarmId -split "/")[-1] $App.OSType = if ($App.kind.ToLower().Contains("linux")){ "Linux" } else { "Windows" } if ($App.Type -eq "Microsoft.Web/sites/slots") { return $App } $currentSubscription = $null $resetDefaultSubscription = $false try { $settings = Az.Functions.internal\Get-AzWebAppApplicationSetting -Name $App.Name ` -ResourceGroupName $App.ResourceGroup ` -ErrorAction SilentlyContinue ` @PSBoundParameters if ($null -eq $settings) { Write-Warning -Message "Failed to retrieve function app settings. 1st attempt" Write-Warning -Message "Setting session context to subscription id '$($App.SubscriptionId)'" $resetDefaultSubscription = $true $currentSubscription = (Get-AzContext).Subscription.Id $null = Select-AzSubscription $App.SubscriptionId $settings = Az.Functions.internal\Get-AzWebAppApplicationSetting -Name $App.Name ` -ResourceGroupName $App.ResourceGroup ` -ErrorAction SilentlyContinue ` @PSBoundParameters if ($null -eq $settings) { # We are unable to get the app settings, return the app Write-Warning -Message "Failed to retrieve function app settings. 2nd attempt." return $App } } } finally { if ($resetDefaultSubscription) { Write-Warning -Message "Resetting session context to subscription id '$currentSubscription'" $null = Select-AzSubscription $currentSubscription } } # Add application settings and runtime $App.ApplicationSettings = ConvertWebAppApplicationSettingToHashtable -ApplicationSetting $settings -RedactAppSettings $App.Runtime = GetRuntime -Settings $settings # Get the app site config $config = GetAzWebAppConfig -Name $App.Name -ResourceGroupName $App.ResourceGroup @PSBoundParameters # Add all site config properties as a hash table $SiteConfig = @{} foreach ($property in $config.PSObject.Properties) { if ($property.Name) { $SiteConfig.Add($property.Name, $property.Value) } } $App.SiteConfig = $SiteConfig return $App } function GetFunctionApps { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [AllowEmptyCollection()] [Object[]] $Apps, [System.String] $Location, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) $paramsToRemove = @( "Apps", "Location" ) foreach ($paramName in $paramsToRemove) { if ($PSBoundParameters.ContainsKey($paramName)) { $PSBoundParameters.Remove($paramName) | Out-Null } } if ($Apps.Count -eq 0) { return } $activityName = "Getting function apps" for ($index = 0; $index -lt $Apps.Count; $index++) { $app = $Apps[$index] $percentageCompleted = [int]((100 * ($index + 1)) / $Apps.Count) $status = "Complete: $($index + 1)/$($Apps.Count) function apps processed." Write-Progress -Activity "Getting function apps" -Status $status -PercentComplete $percentageCompleted if ($app.kind.ToLower().Contains("functionapp")) { if ($Location) { if ($app.Location -eq $Location) { $app = AddFunctionAppSettings -App $app @PSBoundParameters $app } } else { $app = AddFunctionAppSettings -App $app @PSBoundParameters $app } } } Write-Progress -Activity $activityName -Status "Completed" -Completed } function AddFunctionAppPlanWorkerType { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $AppPlan, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("AppPlan")) { $PSBoundParameters.Remove("AppPlan") | Out-Null } # The GetList api for service plan that does not set the Reserved property, which is needed to figure out if the OSType is Linux. # TODO: Remove this code once https://msazure.visualstudio.com/Antares/_workitems/edit/5623226 is fixed. if ($null -eq $AppPlan.Reserved) { # Get the service plan by name does set the Reserved property $planObject = Az.Functions.internal\Get-AzFunctionAppPlan -Name $AppPlan.Name ` -ResourceGroupName $AppPlan.ResourceGroup ` -ErrorAction SilentlyContinue ` @PSBoundParameters $AppPlan = $planObject } $AppPlan.WorkerType = if ($AppPlan.Reserved){ "Linux" } else { "Windows" } return $AppPlan } function GetFunctionAppPlans { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [AllowEmptyCollection()] [Object[]] $Plans, [System.String] $Location, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) $paramsToRemove = @( "Plans", "Location" ) foreach ($paramName in $paramsToRemove) { if ($PSBoundParameters.ContainsKey($paramName)) { $PSBoundParameters.Remove($paramName) | Out-Null } } if ($Plans.Count -eq 0) { return } $activityName = "Getting function app plans" for ($index = 0; $index -lt $Plans.Count; $index++) { $plan = $Plans[$index] $percentageCompleted = [int]((100 * ($index + 1)) / $Plans.Count) $status = "Complete: $($index + 1)/$($Plans.Count) function apps plans processed." Write-Progress -Activity $activityName -Status $status -PercentComplete $percentageCompleted try { if ($Location) { if ($plan.Location -eq $Location) { $plan = AddFunctionAppPlanWorkerType -AppPlan $plan @PSBoundParameters $plan } } else { $plan = AddFunctionAppPlanWorkerType -AppPlan $plan @PSBoundParameters $plan } } catch { continue; } } Write-Progress -Activity $activityName -Status "Completed" -Completed } function ValidateFunctionName { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Name, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) $result = Az.Functions.internal\Test-AzNameAvailability -Type Site @PSBoundParameters if (-not $result.NameAvailable) { $errorMessage = "Function name '$Name' is not available. Please try a different name." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "FunctionAppNameIsNotAvailable" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } } function NormalizeSku { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Sku ) if ($Sku -eq "SHARED") { return "D1" } return $Sku } function CreateFunctionsIdentity { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $InputObject ) if (-not ($InputObject.Name -and $InputObject.ResourceGroupName -and $InputObject.SubscriptionId)) { $errorMessage = "Input object '$InputObject' is missing one or more of the following properties: Name, ResourceGroupName, SubscriptionId" $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "FailedToCreateFunctionsIdentity" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } $functionsIdentity = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.Functions.Models.FunctionsIdentity $functionsIdentity.Name = $InputObject.Name $functionsIdentity.SubscriptionId = $InputObject.SubscriptionId $functionsIdentity.ResourceGroupName = $InputObject.ResourceGroupName return $functionsIdentity } function GetSkuName { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Sku ) if (($Sku -eq "D1") -or ($Sku -eq "SHARED")) { return "SHARED" } elseif (($Sku -eq "B1") -or ($Sku -eq "B2") -or ($Sku -eq "B3") -or ($Sku -eq "BASIC")) { return "BASIC" } elseif (($Sku -eq "S1") -or ($Sku -eq "S2") -or ($Sku -eq "S3")) { return "STANDARD" } elseif (($Sku -eq "P1") -or ($Sku -eq "P2") -or ($Sku -eq "P3")) { return "PREMIUM" } elseif (($Sku -eq "P1V2") -or ($Sku -eq "P2V2") -or ($Sku -eq "P3V2")) { return "PREMIUMV2" } elseif (($Sku -eq "PC2") -or ($Sku -eq "PC3") -or ($Sku -eq "PC4")) { return "PremiumContainer" } elseif (($Sku -eq "EP1") -or ($Sku -eq "EP2") -or ($Sku -eq "EP3")) { return "ElasticPremium" } elseif (($Sku -eq "I1") -or ($Sku -eq "I2") -or ($Sku -eq "I3")) { return "Isolated" } $guidanceUrl = 'https://learn.microsoft.com/azure/azure-functions/functions-premium-plan#plan-and-sku-settings' $errorMessage = "Invalid sku (pricing tier), please refer to '$guidanceUrl' for valid values." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "InvalidSkuPricingTier" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } function ThrowTerminatingError { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $ErrorId, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $ErrorMessage, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.ErrorCategory] $ErrorCategory, [Exception] $Exception, [object] $TargetObject ) if (-not $Exception) { $Exception = New-Object -TypeName System.Exception -ArgumentList $ErrorMessage } $errorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList ($Exception, $ErrorId, $ErrorCategory, $TargetObject) #$PSCmdlet.ThrowTerminatingError($errorRecord) throw $errorRecord } function GetErrorMessage { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNull()] $Response ) if ($Response.Exception.ResponseBody) { try { $details = ConvertFrom-Json $Response.Exception.ResponseBody if ($details.Message) { return $details.Message } } catch { # Ignore the deserialization error } } } function GetSupportedRuntimes { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $OSType ) if ($OSType -eq "Linux") { return $RuntimeToVersionLinux } elseif ($OSType -eq "Windows") { return $RuntimeToVersionWindows } throw "Unknown OS type '$OSType'" } function ValidateFunctionsVersion { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $FunctionsVersion ) # if ($SupportedFunctionsVersion -notcontains $FunctionsVersion) if ($AllFunctionsExtensionVersions -notcontains $FunctionsVersion) { $currentlySupportedFunctionsVersions = $AllFunctionsExtensionVersions -join ' and ' $errorMessage = "Functions version not supported. Currently supported version are: $($currentlySupportedFunctionsVersions)." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "FunctionsVersionNotSupported" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } } function GetDefaultOSType { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Runtime ) $defaultOSType = $RuntimeToDefaultOSType[$Runtime] if (-not $defaultOSType) { # The specified runtime did not match, error out $runtimeOptions = FormatListToString -List @($RuntimeToDefaultOSType.Keys | Sort-Object) $errorMessage = "Runtime '$Runtime' is not supported. Currently supported runtimes: " + $runtimeOptions + "." ThrowRuntimeNotSupportedException -Message $errorMessage -ErrorId "RuntimeNotSupported" } return $defaultOSType } # Returns the stack definition for the given runtime name # function GetStackDefinitionForRuntime { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $FunctionsVersion, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Runtime, [Parameter(Mandatory=$false)] [System.String] $RuntimeVersion, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $OSType ) $supportedRuntimes = GetSupportedRuntimes -OSType $OSType $runtimeJsonDefinition = $null $functionsExtensionVersion = "~$FunctionsVersion" if (-not $supportedRuntimes.ContainsKey($Runtime)) { $runtimeOptions = FormatListToString -List @($supportedRuntimes.Keys | Sort-Object) $errorMessage = "Runtime '$Runtime' on '$OSType' is not supported. Currently supported runtimes: " + $runtimeOptions + "." ThrowRuntimeNotSupportedException -Message $errorMessage -ErrorId "RuntimeNotSupported" } # 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) { $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 } } # 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')) { $errorMessage = "Runtime '$Runtime' in Functions version '$FunctionsVersion' on '$OSType' is not supported." ThrowRuntimeNotSupportedException -Message $errorMessage -ErrorId "RuntimeVersionNotSupported" } Write-Warning "RuntimeVersion not specified. Setting default value to '$RuntimeVersion'. $SetDefaultValueParameterWarningMessage" } if ($Runtime -eq 'Custom') { # Custom runtime does not have a version $runtimeJsonDefinition = $supportedRuntimes[$Runtime] } else { $runtimeJsonDefinition = $supportedRuntimes[$Runtime] | Where-Object { $_.Version -eq $RuntimeVersion } } if (-not $runtimeJsonDefinition) { $errorMessage = "Runtime '$Runtime' version '$RuntimeVersion' in Functions version '$FunctionsVersion' on '$OSType' is not supported." $supporedVersions = @($supportedRuntimes[$Runtime] | Sort-Object -Property Version -Descending | Where-Object { $_.SupportedFunctionsExtensionVersions -contains $functionsExtensionVersion } | Select-Object -ExpandProperty Version) if ($supporedVersions.Count -gt 0) { $runtimeVersionOptions = $supporedVersions -join ", " $errorMessage += " Currently supported runtime versions for '$($Runtime)' are: $runtimeVersionOptions." } ThrowRuntimeNotSupportedException -Message $errorMessage -ErrorId "RuntimeVersionNotSupported" } if ($runtimeJsonDefinition.IsPreview) { # Write a verbose message to the user if the current runtime is in Preview Write-Verbose "Runtime '$Runtime' version '$RuntimeVersion' is in Preview for '$OSType'." -Verbose } return $runtimeJsonDefinition } function ThrowRuntimeNotSupportedException { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Message, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $ErrorId ) $Message += [System.Environment]::NewLine $Message += "For supported languages, please visit 'https://learn.microsoft.com/azure/azure-functions/functions-versions#languages'." $exception = [System.InvalidOperationException]::New($Message) ThrowTerminatingError -ErrorId $ErrorId ` -ErrorMessage $Message ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } function FormatListToString { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [System.String[]] $List ) if ($List.Count -eq 0) { return } $result = "" if ($List.Count -eq 1) { $result = "'" + $List[0] + "'" } else { for ($index = 0; $index -lt ($List.Count - 1); $index++) { $item = $List[$index] $result += "'" + $item + "', " } $result += "'" + $List[$List.Count - 1] + "'" } return $result } function ValidatePlanLocation { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Location, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] [ValidateSet("Dynamic", "ElasticPremium")] $PlanType, [Parameter(Mandatory=$false)] [System.Management.Automation.SwitchParameter] $OSIsLinux, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) $paramsToRemove = @( "PlanType", "OSIsLinux", "Location" ) foreach ($paramName in $paramsToRemove) { if ($PSBoundParameters.ContainsKey($paramName)) { $PSBoundParameters.Remove($paramName) | Out-Null } } $Location = $Location.Trim() $locationContainsSpace = $Location.Contains(" ") $availableLocations = @(Az.Functions.internal\Get-AzFunctionAppAvailableLocation -Sku $PlanType ` -LinuxWorkersEnabled:$OSIsLinux ` @PSBoundParameters | ForEach-Object { $_.Name }) if (-not $locationContainsSpace) { $availableLocations = @($availableLocations | ForEach-Object { $_.Replace(" ", "") }) } if (-not ($availableLocations -contains $Location)) { $errorMessage = "Location is invalid. Use 'Get-AzFunctionAppAvailableLocation' to see available locations for running function apps." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "LocationIsInvalid" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } } function ValidatePremiumPlanLocation { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Location, [Parameter(Mandatory=$false)] [System.Management.Automation.SwitchParameter] $OSIsLinux, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) ValidatePlanLocation -PlanType ElasticPremium @PSBoundParameters } function ValidateConsumptionPlanLocation { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Location, [Parameter(Mandatory=$false)] [System.Management.Automation.SwitchParameter] $OSIsLinux, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) ValidatePlanLocation -PlanType Dynamic @PSBoundParameters } function GetParameterKeyValues { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [System.Collections.Generic.Dictionary[string, object]] [ValidateNotNull()] $PSBoundParametersDictionary, [Parameter(Mandatory=$true)] [System.String[]] [ValidateNotNull()] $ParameterList ) $params = @{} if ($ParameterList.Count -gt 0) { foreach ($paramName in $ParameterList) { if ($PSBoundParametersDictionary.ContainsKey($paramName)) { $params[$paramName] = $PSBoundParametersDictionary[$paramName] } } } return $params } function NewResourceTag { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [hashtable] $Tag ) $resourceTag = [Microsoft.Azure.PowerShell.Cmdlets.Functions.Models.Api20190801.ResourceTags]::new() foreach ($tagName in $Tag.Keys) { $resourceTag.Add($tagName, $Tag[$tagName]) } return $resourceTag } function ParseDockerImage { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $DockerImageName ) # Sample urls: # myacr.azurecr.io/myimage:tag # mcr.microsoft.com/azure-functions/powershell:2.0 if ($DockerImageName.Contains("/")) { $index = $DockerImageName.LastIndexOf("/") $value = $DockerImageName.Substring(0,$index) if ($value.Contains(".") -or $value.Contains(":")) { return $value } } } function GetFunctionAppServicePlanInfo { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $ServerFarmId, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("ServerFarmId")) { $PSBoundParameters.Remove("ServerFarmId") | Out-Null } $planInfo = $null if ($ServerFarmId.Contains("/")) { $parts = $ServerFarmId -split "/" $planName = $parts[-1] $resourceGroupName = $parts[-5] $planInfo = Az.Functions\Get-AzFunctionAppPlan -Name $planName ` -ResourceGroupName $resourceGroupName ` @PSBoundParameters } if (-not $planInfo) { $errorMessage = "Could not determine the current plan of the functionapp." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "CouldNotDetermineFunctionAppPlan" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } return $planInfo } function ValidatePlanSwitchCompatibility { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $CurrentServicePlan, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $NewServicePlan ) if (-not (($CurrentServicePlan.SkuTier -eq "ElasticPremium") -or ($CurrentServicePlan.SkuTier -eq "Dynamic") -or ($NewServicePlan.SkuTier -eq "ElasticPremium") -or ($NewServicePlan.SkuTier -eq "Dynamic"))) { $errorMessage = "Currently the switch is only allowed between a Consumption or an Elastic Premium plan." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "InvalidFunctionAppPlanSwitch" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } } function NewAppSettingObject { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Hashtable] $CurrentAppSetting ) # Create StringDictionaryProperties (hash table) with the app settings $properties = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.Functions.Models.Api20190801.StringDictionaryProperties foreach ($keyName in $currentAppSettings.Keys) { $properties.Add($keyName, $currentAppSettings[$keyName]) } $appSettings = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.Functions.Models.Api20190801.StringDictionary $appSettings.Property = $properties return $appSettings } function ContainsReservedFunctionAppSettingName { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String[]] $AppSettingName ) foreach ($name in $AppSettingName) { if ($ReservedFunctionAppSettingNames.Contains($name)) { return $true } } return $false } function GetFunctionAppByName { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String] $Name, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String] $ResourceGroupName, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) $paramsToRemove = @( "Name", "ResourceGroupName" ) foreach ($paramName in $paramsToRemove) { if ($PSBoundParameters.ContainsKey($paramName)) { $PSBoundParameters.Remove($paramName) | Out-Null } } $existingFunctionApp = Az.Functions\Get-AzFunctionApp -ResourceGroupName $ResourceGroupName ` -Name $Name ` -ErrorAction SilentlyContinue ` @PSBoundParameters if (-not $existingFunctionApp) { $errorMessage = "Function app name '$Name' in resource group name '$ResourceGroupName' does not exist." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "FunctionAppDoesNotExist" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } return $existingFunctionApp } function GetAzWebAppConfig { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String] $Name, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String] $ResourceGroupName, [Switch] $ErrorIfResultIsNull, $SubscriptionId, $HttpPipelineAppend, $HttpPipelinePrepend ) if ($PSBoundParameters.ContainsKey("ErrorIfResultIsNull")) { $PSBoundParameters.Remove("ErrorIfResultIsNull") | Out-Null } $resetDefaultSubscription = $false $webAppConfig = $null $currentSubscription = $null try { $webAppConfig = Az.Functions.internal\Get-AzWebAppConfiguration -ErrorAction SilentlyContinue ` @PSBoundParameters if ($null -eq $webAppConfig) { Write-Warning -Message "Failed to retrieve function app site config. 1st attempt" Write-Warning -Message "Setting session context to subscription id '$($SubscriptionId)'" $resetDefaultSubscription = $true $currentSubscription = (Get-AzContext).Subscription.Id $null = Select-AzSubscription $SubscriptionId $webAppConfig = Az.Functions.internal\Get-AzWebAppConfiguration -ResourceGroupName $ResourceGroupName ` -Name $Name ` -ErrorAction SilentlyContinue ` @PSBoundParameters if ($null -eq $webAppConfig) { Write-Warning -Message "Failed to retrieve function app site config. 2nd attempt." } } } finally { if ($resetDefaultSubscription) { Write-Warning -Message "Resetting session context to subscription id '$currentSubscription'" $null = Select-AzSubscription $currentSubscription } } if ((-not $webAppConfig) -and $ErrorIfResultIsNull) { $errorMessage = "Falied to get config for function app name '$Name' in resource group name '$ResourceGroupName'." $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "FaliedToGetFunctionAppConfig" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } return $webAppConfig } function NewIdentityUserAssignedIdentity { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String[]] $IdentityID ) # If creating user assigned identities, only alphanumeric characters (0-9, a-z, A-Z), the underscore (_) and the hyphen (-) are supported. $msiUserAssignedIdentities = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.Functions.Models.Api20190801.ManagedServiceIdentityUserAssignedIdentities foreach ($id in $IdentityID) { $functionAppUserAssignedIdentitiesValue = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.Functions.Models.Api20190801.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties $msiUserAssignedIdentities.Add($IdentityID, $functionAppUserAssignedIdentitiesValue) } return $msiUserAssignedIdentities } function GetShareSuffix { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Int] $Length = 8 ) # Create char array from 'a' to 'z' $letters = 97..122 | ForEach-Object { [char]$_ } $numbers = 0..9 $alphanumericLowerCase = $letters + $numbers $suffix = [System.Text.StringBuilder]::new() for ($index = 0; $index -lt $Length; $index++) { $value = $alphanumericLowerCase | Get-Random $suffix.Append($value) | Out-Null } $suffix.ToString() } function GetShareName { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $FunctionAppName ) $FunctionAppName = $FunctionAppName.ToLower() if ($env:FunctionsTestMode) { # To support the tests' playback mode, we need to have the same values for each function app creation payload. # Adding this test hook will allows us to have a constant share name when creation an app. return $FunctionAppName } <# Share name restrictions: - A share name must be a valid DNS name. - Share names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character. - Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in share names. - All letters in a share name must be lowercase. - Share names must be from 3 through 63 characters long. Docs: https://learn.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-shares--directories--files--and-metadata#share-names #> # Share name will be function app name + 8 random char suffix with a max length of 60 $MAXLENGTH = 60 $SUFFIXLENGTH = 8 if (($FunctionAppName.Length + $SUFFIXLENGTH) -lt $MAXLENGTH) { $name = $FunctionAppName } else { $endIndex = $MAXLENGTH - $SUFFIXLENGTH - 1 $name = $FunctionAppName.Substring(0, $endIndex) } $suffix = GetShareSuffix -Length $SUFFIXLENGTH $shareName = $name + $suffix return $shareName } Class Runtime { [string]$Name [string]$FullName [string]$Version [bool]$IsPreview [string[]]$SupportedFunctionsExtensionVersions [hashtable]$AppSettingsDictionary [hashtable]$SiteConfigPropertiesDictionary [bool]$IsHidden [bool]$IsDefault [string]$PreferredOs [hashtable]$AppInsightsSettings } function GetBuiltInFunctionAppStacksDefinition { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$false)] [Switch] $DoNotShowWarning ) if (-not $DoNotShowWarning) { $warmingMessage = "Failed to get Function App Stack definitions from ARM API. " $warmingMessage += "Please open an issue at https://github.com/Azure/azure-powershell/issues with the following title: " $warmingMessage += "[Az.Functions] Failed to get Function App Stack definitions from ARM API." Write-Warning $warmingMessage } $filePath = "$PSScriptRoot/FunctionsStack/functionAppStacks.json" $json = Get-Content -Path $filePath -Raw return $json } # Get the Function App Stack definition from the ARM API using the current Azure session # function GetFunctionAppStackDefinition { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param () if ($env:FunctionsTestMode -or ($null -ne $env:SYSTEM_DEFINITIONID -or $null -ne $env:Release_DefinitionId -or $null -ne $env:AZUREPS_HOST_ENVIRONMENT)) { Write-Debug "$DEBUG_PREFIX Running on test mode. Using built in json file definition." $json = GetBuiltInFunctionAppStacksDefinition -DoNotShowWarning return $json } # Make sure there is an active Azure session $context = Get-AzContext -ErrorAction SilentlyContinue if (-not $context) { $errorMessage = "There is no active Azure PowerShell session. Please run 'Connect-AzAccount'" $exception = [System.InvalidOperationException]::New($errorMessage) ThrowTerminatingError -ErrorId "LoginToAzureViaConnectAzAccount" ` -ErrorMessage $errorMessage ` -ErrorCategory ([System.Management.Automation.ErrorCategory]::InvalidOperation) ` -Exception $exception } # Get the ResourceManagerUrl $resourceManagerUrl = $context.Environment.ResourceManagerUrl if ([string]::IsNullOrWhiteSpace($resourceManagerUrl)) { Write-Debug "$DEBUG_PREFIX context does not have a ResourceManagerUrl. Using built in json file definition." $json = GetBuiltInFunctionAppStacksDefinition return $json } if (-not $resourceManagerUrl.EndsWith('/')) { $resourceManagerUrl += '/' } Write-Debug "$DEBUG_PREFIX Get AccessToken." $token = (Get-AzAccessToken).Token $headers = @{ Authorization="Bearer $token" } $params = @{ stackOsType = 'All' removeDeprecatedStacks = 'true' } $apiEndPoint = $resourceManagerUrl + "providers/Microsoft.Web/functionAppStacks?api-version=2020-10-01" $maxNumberOfTries = 3 $currentCount = 1 Write-Debug "$DEBUG_PREFIX Set TLS 1.2" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 do { $result = $null try { Write-Debug "$DEBUG_PREFIX Pull down Function App Stack definitions from ARM API. Attempt $currentCount of $maxNumberOfTries." $result = Invoke-WebRequest -Uri $apiEndPoint -Method Get -Headers $headers -body $params -ErrorAction Stop } catch { $exception = $_ Write-Debug "$DEBUG_PREFIX Failed to get Function App Stack definitions from ARM API. Attempt $currentCount of $maxNumberOfTries. Error: $($exception.Message)" } if ($result) { # Unauthorized if ($result.StatusCode -eq 401) { # Get a new access token, create new headers and retry $token = (Get-AzAccessToken).Token $headers = @{ Authorization = "Bearer $token" } } if ($result.StatusCode -eq 200) { $stackDefinition = $result.Content | ConvertFrom-Json return $stackDefinition.value | ConvertTo-Json -Depth 100 } } $currentCount++ } while ($currentCount -le $maxNumberOfTries) # At this point, we failed to get the stack definition from the ARM API. # Return the built in json file definition $json = GetBuiltInFunctionAppStacksDefinition return $json } function ContainsProperty { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.Object] $Object, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $PropertyName ) $result = $Object | Get-Member -MemberType Properties | Where-Object { $_.Name -eq $PropertyName } return ($null -ne $result) } function ParseMinorVersion { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$false)] [System.String] $StackMinorVersion, [Parameter(Mandatory=$false)] [System.String] $PreferredOs, [Parameter(Mandatory=$true)] [PSCustomObject] $RuntimeSettings, [Parameter(Mandatory=$false)] [System.String] $RuntimeFullName, [Parameter(Mandatory=$false)] [Bool] $StackIsLinux ) # If this FunctionsVersion is not supported, skip it if ($RuntimeSettings.supportedFunctionsExtensionVersions -notcontains "~$DefaultFunctionsVersion") { $supportedFunctionsExtensionVersions = $RuntimeSettings.supportedFunctionsExtensionVersions -join ", " Write-Debug "$DEBUG_PREFIX Minimium required Functions version '$DefaultFunctionsVersion' is not supported. Runtime supported Functions versions: $supportedFunctionsExtensionVersions. Skipping..." return } else { Write-Debug "$DEBUG_PREFIX Minimium required Functions version '$DefaultFunctionsVersion' is supported." } $runtimeName = GetRuntimeName -AppSettingsDictionary $RuntimeSettings.AppSettingsDictionary $version = $null if ($RuntimeName -eq "Java" -and $RuntimeSettings.RuntimeVersion -eq "1.8") { # Java 8 is only supported in Windows. The display value is 8; however, the actual SiteConfig.JavaVersion is 1.8 $version = $StackMinorVersion } else { $version = $RuntimeSettings.RuntimeVersion } $runtimeVersion = GetRuntimeVersion -Version $version -StackIsLinux $StackIsLinux # 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. # We will convert the version to 8, 11, and 17. This change will be reverted for the May 2024 breaking release. if ($RuntimeName -eq "Java") { $runtimeVersion = [int]$runtimeVersion Write-Debug "$DEBUG_PREFIX Runtime version for Java is modified to be compatible with the current release. Current version '$runtimeVersion'" } # 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. # We will convert the version to 6, 7, and 8. This change will be reverted for the May 2024 breaking release. if ($RuntimeName -like "DotNet*") { if ($runtimeVersion.EndsWith(".0")) { $runtimeVersion = [int]$runtimeVersion } Write-Debug "$DEBUG_PREFIX Runtime version for $runtimeName is modified to be compatible with the current release. Current version '$runtimeVersion'" } $runtime = [Runtime]::new() $runtime.Name = $runtimeName $runtime.AppSettingsDictionary = GetDictionary -SettingsDictionary $RuntimeSettings.AppSettingsDictionary $runtime.SiteConfigPropertiesDictionary = GetDictionary -SettingsDictionary $RuntimeSettings.SiteConfigPropertiesDictionary $runtime.AppInsightsSettings = GetDictionary -SettingsDictionary $RuntimeSettings.AppInsightsSettings $runtime.SupportedFunctionsExtensionVersions = GetSupportedFunctionsExtensionVersion -SupportedFunctionsExtensionVersions $RuntimeSettings.SupportedFunctionsExtensionVersions foreach ($propertyName in @("isPreview", "isHidden", "isDefault")) { if (ContainsProperty -Object $RuntimeSettings -PropertyName $propertyName) { Write-Debug "$DEBUG_PREFIX Runtime setting contains '$propertyName'" $runtime.$propertyName = $RuntimeSettings.$propertyName } } # When $env:FunctionsDisplayHiddenRuntimes is set to true, we will display all runtimes if ($runtime.IsHidden -and (-not $env:FunctionsDisplayHiddenRuntimes)) { Write-Debug "$DEBUG_PREFIX Runtime $runtimeName is hidden. Skipping..." return } if ($runtimeVersion -and ($runtimeName -ne "custom")) { Write-Debug "$DEBUG_PREFIX Runtime version: $runtimeVersion" $runtime.Version = $runtimeVersion } else { Write-Debug "$DEBUG_PREFIX Runtime $runtimeName does not have a version." $runtime.Version = "" } if ($RuntimeFullName) { $runtime.FullName = $RuntimeFullName } if ($PreferredOs) { $runtime.PreferredOs = $PreferredOs } $targetOs = if ($StackIsLinux) { 'Linux' } else { 'Windows' } Write-Debug "$DEBUG_PREFIX Runtime '$runtimeName' for '$targetOs' parsed successfully." return $runtime } function GetRuntimeVersion { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$false)] [System.String] $Version, [Parameter(Mandatory=$false)] [Bool] $StackIsLinux ) if (-not $Version) { # Some runtimes do not have a version like custom handler return } if ($StackIsLinux) { $Version = $Version.Split('|')[1] } else { $valuesToReplace = @('v', '~') foreach ($value in $valuesToReplace) { if ($Version.Contains($value)) { $Version = $Version.Replace($value, '') } } } $Version = $Version.Trim() return $Version } function GetDictionary { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [PSCustomObject] $SettingsDictionary ) $dictionary = @{} foreach ($property in $SettingsDictionary.PSObject.Properties) { $dictionary.Add($property.Name, $property.Value) } return $dictionary } function GetRuntimeName { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [PSCustomObject] $AppSettingsDictionary ) $settingHashTable = GetDictionary -SettingsDictionary $AppSettingsDictionary $name = $settingHashTable['FUNCTIONS_WORKER_RUNTIME'] if ($RuntimeToFormattedName.ContainsKey($name)) { return $RuntimeToFormattedName[$name] } return $name } function GetSupportedFunctionsExtensionVersion { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String[]] $SupportedFunctionsExtensionVersions ) $supportedExtensionsVersions = @() foreach ($extensionVersion in $SupportedFunctionsExtensionVersions) { if ($extensionVersion -ge "~$DefaultFunctionsVersion") { $supportedExtensionsVersions += $extensionVersion } } return $supportedExtensionsVersions } function AddRuntimeToDictionary { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param ( [Parameter(Mandatory=$true)] $Runtime, [Parameter(Mandatory=$true)] [hashtable] [Ref]$RuntimeToVersionDictionary ) if ($RuntimeToVersionDictionary.ContainsKey($Runtime.Name)) { $list = $RuntimeToVersionDictionary[$Runtime.Name] } else { $list = New-Object System.Collections.Generic.List[[Runtime]] } $list.Add($Runtime) $RuntimeToVersionDictionary[$Runtime.Name] = $list # Add the runtime name and version to the all runtimes list. This is used for the tab completers if ($AllRuntimeVersions.ContainsKey($runtime.Name)) { $allVersionsList = $AllRuntimeVersions[$Runtime.Name] } else { $allVersionsList = @() } if (-not $allVersionsList.Contains($Runtime.Version)) { $allVersionsList += $Runtime.Version $AllRuntimeVersions[$Runtime.name] = $allVersionsList } # Add Functions extension version to AllFunctionsExtensionVersions. This is used for the tab completers foreach ($extensionVersion in $Runtime.SupportedFunctionsExtensionVersions) { $version = $extensionVersion.Replace("~", "") if (-not $AllFunctionsExtensionVersions.Contains($version)) { $AllFunctionsExtensionVersions.Add($version) } } } function SetLinuxandWindowsSupportedRuntimes { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param () Write-Debug "$DEBUG_PREFIX Build function stack definitions." # Get Function App Runtime Definitions $json = GetFunctionAppStackDefinition $functionAppStackDefinition = $json | ConvertFrom-Json # Build a map of runtime -> runtime version -> runtime version properties foreach ($stackDefinition in $functionAppStackDefinition) { $preferredOs = $stackDefinition.properties.preferredOs $stackName = $stackDefinition.properties.value Write-Debug "$DEBUG_PREFIX Parsing stack name: $stackName" foreach ($majorVersion in $stackDefinition.properties.majorVersions) { foreach ($minorVersion in $majorVersion.minorVersions) { $runtimeFullName = $minorVersion.DisplayText Write-Debug "$DEBUG_PREFIX runtime full name: $runtimeFullName" $stackMinorVersion = $minorVersion.value Write-Debug "$DEBUG_PREFIX stack minor version: $stackMinorVersion" $runtime = $null if (ContainsProperty -Object $minorVersion.stackSettings -PropertyName "windowsRuntimeSettings") { $runtime = ParseMinorVersion -RuntimeSettings $minorVersion.stackSettings.windowsRuntimeSettings ` -RuntimeFullName $runtimeFullName ` -PreferredOs $preferredOs ` -StackMinorVersion $stackMinorVersion if ($runtime) { AddRuntimeToDictionary -Runtime $runtime -RuntimeToVersionDictionary ([Ref]$RuntimeToVersionWindows) } } if (ContainsProperty -Object $minorVersion.stackSettings -PropertyName "linuxRuntimeSettings") { $runtime = ParseMinorVersion -RuntimeSettings $minorVersion.stackSettings.linuxRuntimeSettings ` -RuntimeFullName $runtimeFullName ` -PreferredOs $preferredOs ` -StackIsLinux $true if ($runtime) { AddRuntimeToDictionary -Runtime $runtime -RuntimeToVersionDictionary ([Ref]$RuntimeToVersionLinux) } } } } } } # This method pulls down the Functions stack definitions from the ARM API and builds a list of supported runtimes and runtime versions. # This is used to build the tab completers for the New-AzFunctionApp cmdlet. function RegisterFunctionsTabCompleters { [Microsoft.Azure.PowerShell.Cmdlets.Functions.DoNotExportAttribute()] param () if ($env:FunctionsTabCompletersRegistered) { return } SetLinuxandWindowsSupportedRuntimes # New-AzFunction app ArgumentCompleter for the RuntimeVersion parameter # The values of RuntimeVersion depend on the selection of the Runtime parameter $GetRuntimeVersionCompleter = { param ($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) if ($fakeBoundParameters.ContainsKey('Runtime')) { # RuntimeVersions is defined in SetLinuxandWindowsSupportedRuntimes $AllRuntimeVersions[$fakeBoundParameters.Runtime] | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) } } } # New-AzFunction app ArgumentCompleter for the Runtime parameter $GetAllRuntimesCompleter = { param ($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) $runtimeValues = $AllRuntimeVersions.Keys | Sort-Object | ForEach-Object { $_ } $runtimeValues | Where-Object { $_ -like "$wordToComplete*" } } # New-AzFunction app ArgumentCompleter for the Runtime parameter $GetAllFunctionsVersionsCompleter = { param ($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) $functionsVersions = $AllFunctionsExtensionVersions | Sort-Object | ForEach-Object { $_ } $functionsVersions | Where-Object { $_ -like "$wordToComplete*" } } # Register tab completers Register-ArgumentCompleter -CommandName New-AzFunctionApp -ParameterName FunctionsVersion -ScriptBlock $GetAllFunctionsVersionsCompleter Register-ArgumentCompleter -CommandName New-AzFunctionApp -ParameterName Runtime -ScriptBlock $GetAllRuntimesCompleter Register-ArgumentCompleter -CommandName New-AzFunctionApp -ParameterName RuntimeVersion -ScriptBlock $GetRuntimeVersionCompleter $env:FunctionsTabCompletersRegistered = $true } # SIG # Begin signature block # MIInzgYJKoZIhvcNAQcCoIInvzCCJ7sCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQ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