Skip to content

Commit ad7f4ec

Browse files
authored
Migrate Functions from generation branch (#15385)
Co-authored-by: wyunchi-ms <[email protected]>
1 parent 5b0cab4 commit ad7f4ec

File tree

239 files changed

+37000
-20633
lines changed

Some content is hidden

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

239 files changed

+37000
-20633
lines changed

src/Functions/Az.Functions.psd1

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

99
@{
@@ -47,7 +47,7 @@ PowerShellVersion = '5.1'
4747
DotNetFrameworkVersion = '4.7.2'
4848

4949
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
50-
# CLRVersion = ''
50+
# ClrVersion = ''
5151

5252
# Processor architecture (None, X86, Amd64) required by this module
5353
# ProcessorArchitecture = ''
@@ -115,11 +115,7 @@ PrivateData = @{
115115
# IconUri = ''
116116

117117
# ReleaseNotes of this module
118-
ReleaseNotes = '* Added support in function app creation for Python 3.9 and Node 14 function apps
119-
* Removed support in function app creation for V2, Python 3.6, Node 8, and Node 10 function apps
120-
* 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
121-
* Updated FullyQualifiedErrorId for an invalid Functions version from FunctionsVersionIsInvalid to FunctionsVersionNotSupported
122-
* When creating a Node.js function app, if no runtime version is specified, the default runtime version is set to 14 instead of 12'
118+
# ReleaseNotes = ''
123119

124120
# Prerelease string of this module
125121
# Prerelease = ''

src/Functions/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added two additional app settings (WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING) for Linux Consumption apps. [15124]
22+
* Fixed bug with New-AzFunctionApp when created on Azure Gov. [13379]
23+
* Added Az.Functions cmdlets need to support creating and copying app settings with empty values. [14511]
2124

2225
## Version 3.0.0
2326
* Added support in function app creation for Python 3.9 and Node 14 function apps

src/Functions/build-module.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ $null = New-Item -ItemType Directory -Force -Path $examplesFolder
122122

123123
Write-Host -ForegroundColor Green 'Creating cmdlets for specified models...'
124124
$modelCmdlets = @()
125-
. (Join-Path $PSScriptRoot 'create-model-cmdlets.ps1') -Models $modelCmdlets
125+
if ($modelCmdlets.Count -gt 0) {
126+
. (Join-Path $PSScriptRoot 'create-model-cmdlets.ps1')
127+
CreateModelCmdlet($modelCmdlets)
128+
}
126129

127130
if($NoDocs) {
128131
Write-Host -ForegroundColor Green 'Creating exports...'

src/Functions/create-model-cmdlets.ps1

Lines changed: 128 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -12,154 +12,157 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15-
param([string[]]$Models)
15+
function CreateModelCmdlet {
1616

17-
if ($Models.Count -eq 0)
18-
{
19-
return
20-
}
17+
param([string[]]$Models)
2118

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
19+
if ($Models.Count -eq 0)
20+
{
21+
return
22+
}
2623

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-
} }
24+
$ModelCsPath = Join-Path (Join-Path $PSScriptRoot 'generated\api') 'Models'
25+
$ModuleName = 'Az.Functions'.Split(".")[1]
26+
$OutputDir = Join-Path $PSScriptRoot 'custom\autogen-model-cmdlets'
27+
$null = New-Item -ItemType Directory -Force -Path $OutputDir
3228

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)
29+
$CsFiles = Get-ChildItem -Path $ModelCsPath -Recurse -Filter *.cs
30+
$Content = ''
31+
$null = $CsFiles | ForEach-Object -Process { if ($_.Name.Split('.').count -eq 2 )
32+
{ $Content += get-content $_.fullname -raw
33+
} }
34+
35+
$Tree = [Microsoft.CodeAnalysis.CSharp.SyntaxFactory]::ParseCompilationUnit($Content)
36+
$Nodes = $Tree.ChildNodes().ChildNodes()
37+
foreach ($Model in $Models)
4638
{
47-
$AllInterfaceNodes += $Queue[0]
48-
# Baselist contains the direct parent models.
49-
foreach ($parent in $Queue[0].BaseList.Types)
39+
$InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$Model") }
40+
if ($InterfaceNode.count -eq 0) {
41+
continue
42+
}
43+
# through a queue, we iterate all the parent models.
44+
$Queue = @($InterfaceNode)
45+
$visited = @("I$Model")
46+
$AllInterfaceNodes = @()
47+
while ($Queue.count -ne 0)
5048
{
51-
if (($parent.Type.Right.Identifier.Value -ne 'IJsonSerializable') -and (-not $visited.Contains($parent.Type.Right.Identifier.Value)))
49+
$AllInterfaceNodes += $Queue[0]
50+
# Baselist contains the direct parent models.
51+
foreach ($parent in $Queue[0].BaseList.Types)
5252
{
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
53+
if (($parent.Type.Right.Identifier.Value -ne 'IJsonSerializable') -and (-not $visited.Contains($parent.Type.Right.Identifier.Value)))
54+
{
55+
$Queue = [Array]$Queue + ($Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq $parent.Type.Right.Identifier.Value) })
56+
$visited = [Array]$visited + $parent.Type.Right.Identifier.Value
57+
}
5558
}
59+
$first, $Queue = $Queue
5660
}
57-
$first, $Queue = $Queue
58-
}
5961

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
62+
$Namespace = $InterfaceNode.Parent.Name
63+
$ObjectType = $Model
64+
$ObjectTypeWithNamespace = "${Namespace}.${ObjectType}"
65+
# remove duplicated module name
66+
if ($ObjectType.StartsWith($ModuleName)) {
67+
$ModulePrefix = ''
68+
} else {
69+
$ModulePrefix = $ModuleName
70+
}
71+
$OutputPath = Join-Path -ChildPath "New-Az${ModulePrefix}${ObjectType}Object.ps1" -Path $OutputDir
7072

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)
73+
$ParameterDefineScriptList = New-Object System.Collections.Generic.List[string]
74+
$ParameterAssignScriptList = New-Object System.Collections.Generic.List[string]
75+
foreach ($Node in $AllInterfaceNodes)
7676
{
77-
$Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
78-
$Required = $false
79-
$Description = ""
80-
$Readonly = $False
81-
foreach ($Argument in $Arguments)
77+
foreach ($Member in $Node.Members)
8278
{
83-
if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
79+
$Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
80+
$Required = $false
81+
$Description = ""
82+
$Readonly = $False
83+
foreach ($Argument in $Arguments)
8484
{
85-
$Required = $Argument.Expression.Token.Value
85+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
86+
{
87+
$Required = $Argument.Expression.Token.Value
88+
}
89+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Description")
90+
{
91+
$Description = $Argument.Expression.Token.Value.Trim('.').replace('"', '`"')
92+
}
93+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Readonly")
94+
{
95+
$Readonly = $Argument.Expression.Token.Value
96+
}
8697
}
87-
if ($Argument.NameEquals.Name.Identifier.Value -eq "Description")
98+
if ($Readonly)
8899
{
89-
$Description = $Argument.Expression.Token.Value.Trim('.').replace('"', '`"')
100+
continue
90101
}
91-
if ($Argument.NameEquals.Name.Identifier.Value -eq "Readonly")
102+
$Identifier = $Member.Identifier.Value
103+
$Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
104+
$ParameterDefinePropertyList = New-Object System.Collections.Generic.List[string]
105+
if ($Required)
92106
{
93-
$Readonly = $Argument.Expression.Token.Value
107+
$ParameterDefinePropertyList.Add("Mandatory")
94108
}
109+
if ($Description -ne "")
110+
{
111+
$ParameterDefinePropertyList.Add("HelpMessage=`"${Description}.`"")
112+
}
113+
$ParameterDefineProperty = [System.String]::Join(", ", $ParameterDefinePropertyList)
114+
$ParameterDefineScript = "
115+
[Parameter($ParameterDefineProperty)]
116+
[${Type}]
117+
`$${Identifier}"
118+
$ParameterDefineScriptList.Add($ParameterDefineScript)
119+
$ParameterAssignScriptList.Add("
120+
`$Object.${Identifier} = `$${Identifier}")
95121
}
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}")
119122
}
120-
}
121-
$ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
122-
$ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""
123+
$ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
124+
$ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""
123125

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-
# ----------------------------------------------------------------------------------
126+
$Script = "
127+
# ----------------------------------------------------------------------------------
128+
#
129+
# Copyright Microsoft Corporation
130+
# Licensed under the Apache License, Version 2.0 (the \`"License\`");
131+
# you may not use this file except in compliance with the License.
132+
# You may obtain a copy of the License at
133+
# http://www.apache.org/licenses/LICENSE-2.0
134+
# Unless required by applicable law or agreed to in writing, software
135+
# distributed under the License is distributed on an \`"AS IS\`" BASIS,
136+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137+
# See the License for the specific language governing permissions and
138+
# limitations under the License.
139+
# ----------------------------------------------------------------------------------
138140
139-
<#
140-
.Synopsis
141-
Create a in-memory object for ${ObjectType}
142-
.Description
143-
Create a in-memory object for ${ObjectType}
141+
<#
142+
.Synopsis
143+
Create a in-memory object for ${ObjectType}
144+
.Description
145+
Create a in-memory object for ${ObjectType}
144146
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-
)
147+
.Outputs
148+
${ObjectTypeWithNamespace}
149+
.Link
150+
https://docs.microsoft.com/powershell/module/az.${ModuleName}/new-Az${ModulePrefix}${ObjectType}Object
151+
#>
152+
function New-Az${ModulePrefix}${ObjectType}Object {
153+
[OutputType('${ObjectTypeWithNamespace}')]
154+
[CmdletBinding(PositionalBinding=`$false)]
155+
Param(
156+
${ParameterDefineScript}
157+
)
156158
157-
process {
158-
`$Object = [${ObjectTypeWithNamespace}]::New()
159-
${ParameterAssignScript}
160-
return `$Object
159+
process {
160+
`$Object = [${ObjectTypeWithNamespace}]::New()
161+
${ParameterAssignScript}
162+
return `$Object
163+
}
164+
}
165+
"
166+
Set-Content -Path $OutputPath -Value $Script
161167
}
162-
}
163-
"
164-
Set-Content -Path $OutputPath -Value $Script
165-
}
168+
}

src/Functions/custom/FunctionsStack/LinuxFunctionsStacks.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,40 @@
236236
"frameworks": [],
237237
"isDeprecated": null
238238
}
239+
},
240+
{
241+
"id": null,
242+
"name": "powershell",
243+
"type": "Microsoft.Web/availableStacks?osTypeSelected=LinuxFunctions",
244+
"properties": {
245+
"name": "powershell",
246+
"display": "PowerShell Core",
247+
"dependency": null,
248+
"majorVersions": [
249+
{
250+
"displayVersion": "7.0",
251+
"runtimeVersion": "PowerShell|7",
252+
"supportedFunctionsExtensionVersions": [
253+
"~3"
254+
],
255+
"isDefault": true,
256+
"minorVersions": [],
257+
"applicationInsights": true,
258+
"appSettingsDictionary": {
259+
"FUNCTIONS_WORKER_RUNTIME": "powershell"
260+
},
261+
"siteConfigPropertiesDictionary": {
262+
"use32BitWorkerProcess": false,
263+
"linuxFxVersion": "PowerShell|7"
264+
},
265+
"isPreview": true,
266+
"isDeprecated": false,
267+
"isHidden": true
268+
}
269+
],
270+
"frameworks": [],
271+
"isDeprecated": null
272+
}
239273
}
240274
],
241275
"nextLink": null,

0 commit comments

Comments
 (0)