@@ -18,115 +18,4 @@ if ($env:MSI_SECRET -and (Get-Module -ListAvailable Az.Accounts))
1818
1919# Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
2020# Enable-AzureRmAlias
21- # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
22-
23- function Write-FunctionResult {
24- <#
25- . SYNOPSIS
26- Reports back the output / result of the function app.
27-
28- . DESCRIPTION
29- Reports back the output / result of the function app.
30-
31- . PARAMETER Status
32- Whether the function succeeded or not.
33-
34- . PARAMETER Body
35- Any data to include in the response.
36-
37- . EXAMPLE
38- PS C:\> Write-FunctionResult -Status OK -Body $newUser
39-
40- Reports success while returning the content of $newUser as output
41- #>
42- [CmdletBinding ()]
43- param (
44- [Parameter (Mandatory = $true )]
45- [System.Net.HttpStatusCode ]
46- $Status ,
47-
48- [AllowNull ()]
49- $Body
50- )
51-
52- Push-OutputBinding - Name Response - Value ([HttpResponseContext ]@ {
53- StatusCode = $Status
54- Body = $Body
55- })
56- }
57-
58- function Get-RestParameterValue {
59- <#
60- . SYNOPSIS
61- Extract the exact value of a parameter provided by the user.
62-
63- . DESCRIPTION
64- Extract the exact value of a parameter provided by the user.
65- Expects either query or body parameters from the rest call to the http trigger.
66-
67- . PARAMETER Request
68- The request object provided as part of the function call.
69-
70- . PARAMETER Name
71- The name of the parameter to provide.
72-
73- . EXAMPLE
74- PS C:\> Get-RestParameterValue -Request $Request -Name Type
75-
76- Returns the value of the parameter "Type", as provided by the caller
77- #>
78- [CmdletBinding ()]
79- param (
80- [Parameter (Mandatory = $true )]
81- $Request ,
82-
83- [Parameter (Mandatory = $true )]
84- [string ]
85- $Name
86- )
87-
88- if ($Request.Query .$Name ) {
89- return $Request.Query .$Name
90- }
91- $Request.Body .$Name
92- }
93-
94- function Get-RestParameter {
95- <#
96- . SYNOPSIS
97- Parses the rest request parameters for all values matching parameters on the specified command.
98-
99- . DESCRIPTION
100- Parses the rest request parameters for all values matching parameters on the specified command.
101- Returns a hashtable ready for splatting.
102- Does NOT assert mandatory parameters are specified, so command invocation may fail.
103-
104- . PARAMETER Request
105- The original rest request object, containing the caller's information such as parameters.
106-
107- . PARAMETER Command
108- The command to which to bind input parameters.
109-
110- . EXAMPLE
111- PS C:\> Get-RestParameter -Request $Request -Command Get-AzUser
112-
113- Retrieves all parameters on the incoming request that match a parameter on Get-AzUser
114- #>
115- [CmdletBinding ()]
116- Param (
117- [Parameter (Mandatory = $true )]
118- $Request ,
119-
120- [Parameter (Mandatory = $true )]
121- [string ]
122- $Command
123- )
124-
125- $commandInfo = Get-Command - Name $Command
126- $results = @ { }
127- foreach ($parameter in $commandInfo.Parameters.Keys ) {
128- $value = Get-RestParameterValue - Request $Request - Name $parameter
129- if ($null -ne $value ) { $results [$parameter ] = $value }
130- }
131- $results
132- }
21+ # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
0 commit comments