Skip to content

Commit bd6de13

Browse files
dolauliazurepowershell
andauthored
[Az.Functions] Release with some new features and bug fix (#15027)
* Move Functions to master * Updated changelog for function * Clean some unused docs in function (#15028) * Suppress break change warnings for functions (#15031) Co-authored-by: azurepowershell <[email protected]>
1 parent 8f92bd6 commit bd6de13

File tree

526 files changed

+27493
-21270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

526 files changed

+27493
-21270
lines changed

src/Functions/Az.Functions.format.ps1xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18150,15 +18150,6 @@
1815018150
</ViewSelectedBy>
1815118151
<TableControl>
1815218152
<TableHeaders>
18153-
<TableColumnHeader>
18154-
<Label>PublishingPassword</Label>
18155-
</TableColumnHeader>
18156-
<TableColumnHeader>
18157-
<Label>PublishingPasswordHash</Label>
18158-
</TableColumnHeader>
18159-
<TableColumnHeader>
18160-
<Label>PublishingPasswordHashSalt</Label>
18161-
</TableColumnHeader>
1816218153
<TableColumnHeader>
1816318154
<Label>PublishingUserName</Label>
1816418155
</TableColumnHeader>
@@ -18169,15 +18160,6 @@
1816918160
<TableRowEntries>
1817018161
<TableRowEntry>
1817118162
<TableColumnItems>
18172-
<TableColumnItem>
18173-
<PropertyName>PublishingPassword</PropertyName>
18174-
</TableColumnItem>
18175-
<TableColumnItem>
18176-
<PropertyName>PublishingPasswordHash</PropertyName>
18177-
</TableColumnItem>
18178-
<TableColumnItem>
18179-
<PropertyName>PublishingPasswordHashSalt</PropertyName>
18180-
</TableColumnItem>
1818118163
<TableColumnItem>
1818218164
<PropertyName>PublishingUserName</PropertyName>
1818318165
</TableColumnItem>

src/Functions/Az.Functions.psd1

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 10/23/2020
6+
# Generated on: 5/18/2021
77
#
88

99
@{
@@ -56,16 +56,16 @@ DotNetFrameworkVersion = '4.7.2'
5656
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.2.8'; })
5757

5858
# Assemblies that must be loaded prior to importing this module
59-
RequiredAssemblies = 'bin\Az.Functions.private.dll'
59+
RequiredAssemblies = './bin/Az.Functions.private.dll'
6060

6161
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
62-
ScriptsToProcess = 'custom\HelperFunctions.ps1'
62+
ScriptsToProcess = './custom/HelperFunctions.ps1'
6363

6464
# Type files (.ps1xml) to be loaded when importing this module
65-
TypesToProcess = 'custom\Functions.types.ps1xml'
65+
TypesToProcess = './custom/Functions.types.ps1xml'
6666

6767
# Format files (.ps1xml) to be loaded when importing this module
68-
FormatsToProcess = 'Az.Functions.format.ps1xml', 'custom\Functions.format.ps1xml'
68+
FormatsToProcess = './Az.Functions.format.ps1xml', './custom/Functions.format.ps1xml'
6969

7070
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
7171
# NestedModules = @()
@@ -115,13 +115,7 @@ PrivateData = @{
115115
# IconUri = ''
116116

117117
# ReleaseNotes of this module
118-
ReleaseNotes = '* [Breaking Change] Removed ''IncludeSlot'' switch parameter from all but one parameter set of ''Get-AzFunctionApp''. The cmdlet now supports retrieving deployment slots in the results when ''-IncludeSlot'' is specified.
119-
* Updated ''New-AzFunctionApp'':
120-
- Fixed -DisableApplicationInsights so that no application insights project is created when this option is specified. [#12728]
121-
- [Breaking Change] Removed support to create PowerShell 6.2 function apps.
122-
- [Breaking Change] Changed the default runtime version in Functions version 3 on Windows for PowerShell function apps from 6.2 to 7.0 when the RuntimeVersion parameter is not specified.
123-
- [Breaking Change] Changed the default runtime version in Functions version 3 on Windows and Linux for Node function apps from 10 to 12 when the RuntimeVersion parameter is not specified.
124-
- [Breaking Change] Changed the default runtime version in Functions version 3 on Linux for Python function apps from 3.7 to 3.8 when the RuntimeVersion parameter is not specified.'
118+
# ReleaseNotes = ''
125119

126120
# Prerelease string of this module
127121
# Prerelease = ''

src/Functions/Az.Functions.psm1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
}
2525
}
2626
if(-not $accountsModule) {
27-
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.8.1' } | Measure-Object).Count -gt 0
27+
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.2.3' } | Measure-Object).Count -gt 0
2828
if($hasAdequateVersion) {
29-
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.8.1 -Scope Global -PassThru
29+
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.2.3 -Scope Global -PassThru
3030
}
3131
}
3232
}
3333

3434
if(-not $accountsModule) {
35-
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
36-
} elseif (($accountsModule.Version -lt [System.Version]'1.8.1') -and (-not $localAccounts)) {
37-
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
35+
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
36+
} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) {
37+
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
3838
}
3939
Write-Information "Loaded Module '$($accountsModule.Name)'"
4040

src/Functions/ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added support in function app creation for Python 3.9 and Node 14 function apps
22+
* Removed support in function app creation for V2, Python 3.6, Node 8, and Node 10 function apps
23+
* Updated IdentityID parameter from string to string array in Update-AzFunctionApp. This is to be consistent with New-AzFunctionApp which has the same parameter as a string array
24+
* Updated FullyQualifiedErrorId for an invalid Functions version from FunctionsVersionIsInvalid to FunctionsVersionNotSupported
25+
* When creating a Node.js function app, if no runtime version is specified, the default runtime version is set to 14 instead of 12
2126

2227
## Version 2.0.0
2328
* [Breaking Change] Removed `IncludeSlot` switch parameter from all but one parameter set of `Get-AzFunctionApp`. The cmdlet now supports retrieving deployment slots in the results when `-IncludeSlot` is specified.

src/Functions/build-module.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ $moduleName = 'Az.Functions'
120120
$examplesFolder = Join-Path $PSScriptRoot 'examples'
121121
$null = New-Item -ItemType Directory -Force -Path $examplesFolder
122122

123+
Write-Host -ForegroundColor Green 'Creating cmdlets for specified models...'
124+
$modelCmdlets = @()
125+
. (Join-Path $PSScriptRoot 'create-model-cmdlets.ps1') -Models $modelCmdlets
126+
123127
if($NoDocs) {
124128
Write-Host -ForegroundColor Green 'Creating exports...'
125-
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs
129+
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs -ExamplesFolder $examplesFolder
126130
} else {
127131
Write-Host -ForegroundColor Green 'Creating exports and docs...'
128132
$moduleDescription = 'Microsoft Azure PowerShell - Azure Functions service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.\n\nFor information on Azure Functions, please visit the following: https://docs.microsoft.com/azure/azure-functions/'

src/Functions/check-dependencies.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ if(Test-Path -Path $localModulesPath) {
4646
$env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath"
4747
}
4848

49-
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.8.1'
49+
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '2.2.3'
5050
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'
5151

5252
$tools = Join-Path $PSScriptRoot 'tools'
5353
$resourceDir = Join-Path $tools 'Resources'
5454
$resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestSupport.psm1'
5555

56-
if ($Resources.IsPresent -and (-not (Test-Path -Path $resourceModule))) {
56+
if ($Resources.IsPresent -and ((-not (Test-Path -Path $resourceModule)) -or $RegenerateSupportModule.IsPresent)) {
5757
Write-Host -ForegroundColor Green "Building local Resource module used for test..."
5858
Set-Location $resourceDir
59-
$null = autorest-beta .\readme.md --output-folder=$HOME/.PSSharedModules/Resources
59+
$null = autorest .\readme.md --use:@autorest/powershell@3.0.414 --output-folder=$HOME/.PSSharedModules/Resources
6060
$null = Copy-Item custom/* $HOME/.PSSharedModules/Resources/custom/
6161
Set-Location $HOME/.PSSharedModules/Resources
6262
$null = .\build-module.ps1
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
param([string[]]$Models)
16+
17+
if ($Models.Count -eq 0)
18+
{
19+
return
20+
}
21+
22+
$ModelCsPath = Join-Path (Join-Path $PSScriptRoot 'generated\api') 'Models'
23+
$ModuleName = 'Az.Functions'.Split(".")[1]
24+
$OutputDir = Join-Path $PSScriptRoot 'custom\autogen-model-cmdlets'
25+
$null = New-Item -ItemType Directory -Force -Path $OutputDir
26+
27+
$CsFiles = Get-ChildItem -Path $ModelCsPath -Recurse -Filter *.cs
28+
$Content = ''
29+
$null = $CsFiles | ForEach-Object -Process { if ($_.Name.Split('.').count -eq 2 )
30+
{ $Content += get-content $_.fullname -raw
31+
} }
32+
33+
$Tree = [Microsoft.CodeAnalysis.CSharp.SyntaxFactory]::ParseCompilationUnit($Content)
34+
$Nodes = $Tree.ChildNodes().ChildNodes()
35+
foreach ($Model in $Models)
36+
{
37+
$InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$Model") }
38+
if ($InterfaceNode.count -eq 0) {
39+
continue
40+
}
41+
# through a queue, we iterate all the parent models.
42+
$Queue = @($InterfaceNode)
43+
$visited = @("I$Model")
44+
$AllInterfaceNodes = @()
45+
while ($Queue.count -ne 0)
46+
{
47+
$AllInterfaceNodes += $Queue[0]
48+
# Baselist contains the direct parent models.
49+
foreach ($parent in $Queue[0].BaseList.Types)
50+
{
51+
if (($parent.Type.Right.Identifier.Value -ne 'IJsonSerializable') -and (-not $visited.Contains($parent.Type.Right.Identifier.Value)))
52+
{
53+
$Queue = [Array]$Queue + ($Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq $parent.Type.Right.Identifier.Value) })
54+
$visited = [Array]$visited + $parent.Type.Right.Identifier.Value
55+
}
56+
}
57+
$first, $Queue = $Queue
58+
}
59+
60+
$Namespace = $InterfaceNode.Parent.Name
61+
$ObjectType = $Model
62+
$ObjectTypeWithNamespace = "${Namespace}.${ObjectType}"
63+
# remove duplicated module name
64+
if ($ObjectType.StartsWith($ModuleName)) {
65+
$ModulePrefix = ''
66+
} else {
67+
$ModulePrefix = $ModuleName
68+
}
69+
$OutputPath = Join-Path -ChildPath "New-Az${ModulePrefix}${ObjectType}Object.ps1" -Path $OutputDir
70+
71+
$ParameterDefineScriptList = New-Object System.Collections.Generic.List[string]
72+
$ParameterAssignScriptList = New-Object System.Collections.Generic.List[string]
73+
foreach ($Node in $AllInterfaceNodes)
74+
{
75+
foreach ($Member in $Node.Members)
76+
{
77+
$Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
78+
$Required = $false
79+
$Description = ""
80+
$Readonly = $False
81+
foreach ($Argument in $Arguments)
82+
{
83+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
84+
{
85+
$Required = $Argument.Expression.Token.Value
86+
}
87+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Description")
88+
{
89+
$Description = $Argument.Expression.Token.Value.Trim('.').replace('"', '`"')
90+
}
91+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Readonly")
92+
{
93+
$Readonly = $Argument.Expression.Token.Value
94+
}
95+
}
96+
if ($Readonly)
97+
{
98+
continue
99+
}
100+
$Identifier = $Member.Identifier.Value
101+
$Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
102+
$ParameterDefinePropertyList = New-Object System.Collections.Generic.List[string]
103+
if ($Required)
104+
{
105+
$ParameterDefinePropertyList.Add("Mandatory")
106+
}
107+
if ($Description -ne "")
108+
{
109+
$ParameterDefinePropertyList.Add("HelpMessage=`"${Description}.`"")
110+
}
111+
$ParameterDefineProperty = [System.String]::Join(", ", $ParameterDefinePropertyList)
112+
$ParameterDefineScript = "
113+
[Parameter($ParameterDefineProperty)]
114+
[${Type}]
115+
`$${Identifier}"
116+
$ParameterDefineScriptList.Add($ParameterDefineScript)
117+
$ParameterAssignScriptList.Add("
118+
`$Object.${Identifier} = `$${Identifier}")
119+
}
120+
}
121+
$ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
122+
$ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""
123+
124+
$Script = "
125+
# ----------------------------------------------------------------------------------
126+
#
127+
# Copyright Microsoft Corporation
128+
# Licensed under the Apache License, Version 2.0 (the \`"License\`");
129+
# you may not use this file except in compliance with the License.
130+
# You may obtain a copy of the License at
131+
# http://www.apache.org/licenses/LICENSE-2.0
132+
# Unless required by applicable law or agreed to in writing, software
133+
# distributed under the License is distributed on an \`"AS IS\`" BASIS,
134+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135+
# See the License for the specific language governing permissions and
136+
# limitations under the License.
137+
# ----------------------------------------------------------------------------------
138+
139+
<#
140+
.Synopsis
141+
Create a in-memory object for ${ObjectType}
142+
.Description
143+
Create a in-memory object for ${ObjectType}
144+
145+
.Outputs
146+
${ObjectTypeWithNamespace}
147+
.Link
148+
https://docs.microsoft.com/powershell/module/az.${ModuleName}/new-Az${ModulePrefix}${ObjectType}Object
149+
#>
150+
function New-Az${ModulePrefix}${ObjectType}Object {
151+
[OutputType('${ObjectTypeWithNamespace}')]
152+
[CmdletBinding(PositionalBinding=`$false)]
153+
Param(
154+
${ParameterDefineScript}
155+
)
156+
157+
process {
158+
`$Object = [${ObjectTypeWithNamespace}]::New()
159+
${ParameterAssignScript}
160+
return `$Object
161+
}
162+
}
163+
"
164+
Set-Content -Path $OutputPath -Value $Script
165+
}

0 commit comments

Comments
 (0)