Skip to content

Commit 54e74a6

Browse files
committed
Add help and ShouldProcess
1 parent e1b3725 commit 54e74a6

File tree

4 files changed

+213
-13
lines changed

4 files changed

+213
-13
lines changed

experiments/Websites.Experiments/AzureRM.Websites.Experiments.psm1

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function New-AzWebAppJustDoIt
129129
#>
130130
function New-AzWebApp
131131
{
132-
[CmdletBinding()]
132+
[CmdletBinding(SupportsShouldProcess=$true)]
133133
[OutputType([Microsoft.Azure.Management.WebSites.Models.Site])]
134134
param(
135135
[string][Parameter(Mandatory=$false)][alias("Name")]$WebAppName,
@@ -212,7 +212,8 @@ function New-AzWebApp
212212
[string]$appName = Get-WebAppName `
213213
-ProvidedParameters $PSBoundParameters `
214214
-WebSitesClient $webSitesClient
215-
Write-Progress `
215+
if ($PSCmdlet.ShouldProcess($appName, "Create an Azure Web App")) {
216+
Write-Progress `
216217
-Activity $mainActivity `
217218
-CurrentOperation "Getting Resource Group information."
218219
[hashtable]$groupInfo = Get-ResourceGroupInfo `
@@ -274,7 +275,8 @@ function New-AzWebApp
274275

275276
if (($PSBoundParameters.ContainsKey('AddRemote') -or $PSBoundParameters.ContainsKey('Auto')) -and $webapp) {
276277
Add-Remote -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath
277-
}
278+
}
279+
}
278280
}
279281

280282
END {}
@@ -569,7 +571,7 @@ function Get-WebSitesClient
569571
#>
570572
function New-AzWebAppGrayParam
571573
{
572-
[CmdletBinding()]
574+
[CmdletBinding(SupportsShouldProcess=$true)]
573575
[OutputType([Microsoft.Azure.Management.WebSites.Models.Site])]
574576
param(
575577
[string][Parameter(Mandatory=$false)][alias("Name")]$WebAppName,
@@ -628,6 +630,8 @@ function New-AzWebAppGrayParam
628630
-Activity $mainActivity `
629631
-CurrentOperation "Getting App Name information."
630632
[string]$appName = Get-WebAppNameGrayParam $PSBoundParameters $webSitesClient
633+
if ($PSCmdlet.ShouldProcess($appName, "Create an Azure Web App")) {
634+
631635
Write-Progress `
632636
-Activity $mainActivity `
633637
-CurrentOperation "Getting Resource Group information."
@@ -678,7 +682,8 @@ function New-AzWebAppGrayParam
678682

679683
Write-Output $webapp
680684

681-
Add-RemoteGrayParam -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath
685+
Add-RemoteGrayParam -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath
686+
}
682687
}
683688

684689
END {}

experiments/Websites.Experiments/help/AzureRM.Websites.Experiments-help.xml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@
6565
<maml:uri /></dev:type>
6666
<dev:defaultValue>False</dev:defaultValue>
6767
</command:parameter>
68+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
69+
<maml:Description><maml:para>{{Fill Location Description}}
70+
</maml:para>
71+
</maml:Description>
72+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
73+
<dev:type><maml:name>String</maml:name>
74+
<maml:uri /></dev:type>
75+
<dev:defaultValue>None</dev:defaultValue>
76+
</command:parameter>
77+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
78+
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
79+
</maml:para>
80+
</maml:Description>
81+
<dev:type><maml:name>SwitchParameter</maml:name>
82+
<maml:uri /></dev:type>
83+
<dev:defaultValue>False</dev:defaultValue>
84+
</command:parameter>
85+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
86+
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
87+
</maml:para>
88+
</maml:Description>
89+
<dev:type><maml:name>SwitchParameter</maml:name>
90+
<maml:uri /></dev:type>
91+
<dev:defaultValue>False</dev:defaultValue>
92+
</command:parameter>
6893
</command:syntaxItem>
6994
</command:syntax>
7095
<command:parameters><command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>AddRemote</maml:name>
@@ -103,6 +128,15 @@
103128
<maml:uri /></dev:type>
104129
<dev:defaultValue>None</dev:defaultValue>
105130
</command:parameter>
131+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
132+
<maml:Description><maml:para>{{Fill Location Description}}
133+
</maml:para>
134+
</maml:Description>
135+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
136+
<dev:type><maml:name>String</maml:name>
137+
<maml:uri /></dev:type>
138+
<dev:defaultValue>None</dev:defaultValue>
139+
</command:parameter>
106140
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="Group"><maml:name>ResourceGroupName</maml:name>
107141
<maml:Description><maml:para>The name of the resource group for the Website.
108142
</maml:para>
@@ -121,6 +155,24 @@
121155
<maml:uri /></dev:type>
122156
<dev:defaultValue>None</dev:defaultValue>
123157
</command:parameter>
158+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
159+
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
160+
</maml:para>
161+
</maml:Description>
162+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
163+
<dev:type><maml:name>SwitchParameter</maml:name>
164+
<maml:uri /></dev:type>
165+
<dev:defaultValue>False</dev:defaultValue>
166+
</command:parameter>
167+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
168+
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
169+
</maml:para>
170+
</maml:Description>
171+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
172+
<dev:type><maml:name>SwitchParameter</maml:name>
173+
<maml:uri /></dev:type>
174+
<dev:defaultValue>False</dev:defaultValue>
175+
</command:parameter>
124176
</command:parameters>
125177
<command:inputTypes><command:inputType><dev:type><maml:name>None</maml:name>
126178
</dev:type>
@@ -219,6 +271,31 @@
219271
<maml:uri /></dev:type>
220272
<dev:defaultValue>False</dev:defaultValue>
221273
</command:parameter>
274+
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
275+
<maml:Description><maml:para>{{Fill Location Description}}
276+
</maml:para>
277+
</maml:Description>
278+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
279+
<dev:type><maml:name>String</maml:name>
280+
<maml:uri /></dev:type>
281+
<dev:defaultValue>None</dev:defaultValue>
282+
</command:parameter>
283+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
284+
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
285+
</maml:para>
286+
</maml:Description>
287+
<dev:type><maml:name>SwitchParameter</maml:name>
288+
<maml:uri /></dev:type>
289+
<dev:defaultValue>False</dev:defaultValue>
290+
</command:parameter>
291+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
292+
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
293+
</maml:para>
294+
</maml:Description>
295+
<dev:type><maml:name>SwitchParameter</maml:name>
296+
<maml:uri /></dev:type>
297+
<dev:defaultValue>False</dev:defaultValue>
298+
</command:parameter>
222299
</command:syntaxItem>
223300
</command:syntax>
224301
<command:parameters><command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>AddRemote</maml:name>
@@ -257,6 +334,15 @@
257334
<maml:uri /></dev:type>
258335
<dev:defaultValue>None</dev:defaultValue>
259336
</command:parameter>
337+
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none"><maml:name>Location</maml:name>
338+
<maml:Description><maml:para>{{Fill Location Description}}
339+
</maml:para>
340+
</maml:Description>
341+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
342+
<dev:type><maml:name>String</maml:name>
343+
<maml:uri /></dev:type>
344+
<dev:defaultValue>None</dev:defaultValue>
345+
</command:parameter>
260346
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="Group"><maml:name>ResourceGroupName</maml:name>
261347
<maml:Description><maml:para>The name of the resource group to create the website in.
262348
</maml:para>
@@ -275,6 +361,24 @@
275361
<maml:uri /></dev:type>
276362
<dev:defaultValue>None</dev:defaultValue>
277363
</command:parameter>
364+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="cf"><maml:name>Confirm</maml:name>
365+
<maml:Description><maml:para>Prompts you for confirmation before running the cmdlet.
366+
</maml:para>
367+
</maml:Description>
368+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
369+
<dev:type><maml:name>SwitchParameter</maml:name>
370+
<maml:uri /></dev:type>
371+
<dev:defaultValue>False</dev:defaultValue>
372+
</command:parameter>
373+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="wi"><maml:name>WhatIf</maml:name>
374+
<maml:Description><maml:para>Shows what would happen if the cmdlet runs. The cmdlet is not run.
375+
</maml:para>
376+
</maml:Description>
377+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
378+
<dev:type><maml:name>SwitchParameter</maml:name>
379+
<maml:uri /></dev:type>
380+
<dev:defaultValue>False</dev:defaultValue>
381+
</command:parameter>
278382
</command:parameters>
279383
<command:inputTypes><command:inputType><dev:type><maml:name>None</maml:name>
280384
</dev:type>

experiments/Websites.Experiments/help/New-AzWebApp.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Create a new Azure AppService website and attach it to a git repository.
1313

1414
```
1515
New-AzWebApp [[-WebAppName] <String>] [[-ResourceGroupName] <String>] [[-AppServicePlan] <String>] [-Auto]
16-
[-AddRemote] [[-GitRepositoryPath] <String>]
16+
[-AddRemote] [[-GitRepositoryPath] <String>] [-WhatIf] [-Confirm] [-Location <String>] [<CommonParameters>]
1717
```
1818

1919
## DESCRIPTION
@@ -35,7 +35,6 @@ PS C:\> New-AzWebApp contosoWebApp -Auto
3535

3636
Creates a web application using default settings.
3737

38-
3938
## PARAMETERS
4039

4140
### -AddRemote
@@ -98,6 +97,21 @@ Accept pipeline input: False
9897
Accept wildcard characters: False
9998
```
10099
100+
### -Location
101+
{{Fill Location Description}}
102+
103+
```yaml
104+
Type: String
105+
Parameter Sets: (All)
106+
Aliases:
107+
108+
Required: False
109+
Position: Named
110+
Default value: None
111+
Accept pipeline input: False
112+
Accept wildcard characters: False
113+
```
114+
101115
### -ResourceGroupName
102116
The name of the resource group for the Website.
103117
@@ -128,17 +142,48 @@ Accept pipeline input: False
128142
Accept wildcard characters: False
129143
```
130144
145+
### -Confirm
146+
Prompts you for confirmation before running the cmdlet.
147+
148+
```yaml
149+
Type: SwitchParameter
150+
Parameter Sets: (All)
151+
Aliases: cf
152+
153+
Required: False
154+
Position: Named
155+
Default value: None
156+
Accept pipeline input: False
157+
Accept wildcard characters: False
158+
```
159+
160+
### -WhatIf
161+
Shows what would happen if the cmdlet runs. The cmdlet is not run.
162+
163+
```yaml
164+
Type: SwitchParameter
165+
Parameter Sets: (All)
166+
Aliases: wi
167+
168+
Required: False
169+
Position: Named
170+
Default value: None
171+
Accept pipeline input: False
172+
Accept wildcard characters: False
173+
```
174+
175+
### CommonParameters
176+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
177+
131178
## INPUTS
132179
133180
### None
134181
135-
136182
## OUTPUTS
137183
138184
### Microsoft.Azure.Management.WebSites.Models.Site
139185
Details about the created website, including URL and github repo url.
140186
141-
142187
## NOTES
143188
144189
## RELATED LINKS

experiments/Websites.Experiments/help/New-AzWebAppGrayParam.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Create an Azure Website using Azure App Service.
1313

1414
```
1515
New-AzWebAppGrayParam [[-WebAppName] <String>] [[-ResourceGroupName] <String>] [[-AppServicePlan] <String>]
16-
[-Auto] [-AddRemote] [[-GitRepositoryPath] <String>] [-Location <string>]
16+
[-Auto] [-AddRemote] [[-GitRepositoryPath] <String>] [-WhatIf] [-Confirm] -Location <String>
17+
[<CommonParameters>]
1718
```
1819

1920
## DESCRIPTION
2021
Create an Azure Website using Azure App Service. This cmdlet uses the 'Gray Parameter' experience, which will prompt the user with default
2122
values for parameters that are not provided. Using -Auto indicates that further prompting for defaults should not occur.
2223

23-
2424
## EXAMPLES
2525

2626
### Example 1
@@ -92,6 +92,21 @@ Accept pipeline input: False
9292
Accept wildcard characters: False
9393
```
9494
95+
### -Location
96+
{{Fill Location Description}}
97+
98+
```yaml
99+
Type: String
100+
Parameter Sets: (All)
101+
Aliases:
102+
103+
Required: True
104+
Position: Named
105+
Default value: None
106+
Accept pipeline input: False
107+
Accept wildcard characters: False
108+
```
109+
95110
### -ResourceGroupName
96111
The name of the resource group to create the website in.
97112
@@ -122,17 +137,48 @@ Accept pipeline input: False
122137
Accept wildcard characters: False
123138
```
124139
140+
### -Confirm
141+
Prompts you for confirmation before running the cmdlet.
142+
143+
```yaml
144+
Type: SwitchParameter
145+
Parameter Sets: (All)
146+
Aliases: cf
147+
148+
Required: False
149+
Position: Named
150+
Default value: None
151+
Accept pipeline input: False
152+
Accept wildcard characters: False
153+
```
154+
155+
### -WhatIf
156+
Shows what would happen if the cmdlet runs. The cmdlet is not run.
157+
158+
```yaml
159+
Type: SwitchParameter
160+
Parameter Sets: (All)
161+
Aliases: wi
162+
163+
Required: False
164+
Position: Named
165+
Default value: None
166+
Accept pipeline input: False
167+
Accept wildcard characters: False
168+
```
169+
170+
### CommonParameters
171+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
172+
125173
## INPUTS
126174
127175
### None
128176
129-
130177
## OUTPUTS
131178
132179
### Microsoft.Azure.Management.WebSites.Models.Site
133180
Details about the created website, including its URL.
134181
135-
136182
## NOTES
137183
138184
## RELATED LINKS

0 commit comments

Comments
 (0)