...
1---
2external help file: -help.xml
3Module Name:
4online version:
5schema: 2.0.0
6---
7
8# Remove-TestResources.ps1
9
10## SYNOPSIS
11Deletes the resource group deployed for a service directory from Azure.
12
13## SYNTAX
14
15### Default (Default)
16```
17Remove-TestResources.ps1 [-BaseName <String>] [-SubscriptionId <String>] [-ServiceDirectory] <String>
18 [-Environment <String>] [-Force] [-RemoveTestResourcesRemainingArguments <Object>] [-WhatIf] [-Confirm]
19 [<CommonParameters>]
20```
21
22### Default+Provisioner
23```
24Remove-TestResources.ps1 -BaseName <String> -TenantId <String> [-SubscriptionId <String>]
25 -ProvisionerApplicationId <String> -ProvisionerApplicationSecret <String> [[-ServiceDirectory] <String>]
26 [-Environment <String>] [-Force] [-RemoveTestResourcesRemainingArguments <Object>] [-WhatIf] [-Confirm]
27 [<CommonParameters>]
28```
29
30### ResourceGroup+Provisioner
31```
32Remove-TestResources.ps1 -ResourceGroupName <String> -TenantId <String> [-SubscriptionId <String>]
33 -ProvisionerApplicationId <String> -ProvisionerApplicationSecret <String> [[-ServiceDirectory] <String>]
34 [-Environment <String>] [-CI] [-Force] [-RemoveTestResourcesRemainingArguments <Object>] [-WhatIf] [-Confirm]
35 [<CommonParameters>]
36```
37
38### ResourceGroup
39```
40Remove-TestResources.ps1 -ResourceGroupName <String> [-SubscriptionId <String>] [[-ServiceDirectory] <String>]
41 [-Environment <String>] [-CI] [-Force] [-RemoveTestResourcesRemainingArguments <Object>] [-WhatIf] [-Confirm]
42 [<CommonParameters>]
43```
44
45## DESCRIPTION
46Removes a resource group and all its resources previously deployed using
47New-TestResources.ps1.
48If you are not currently logged into an account in the Az PowerShell module,
49you will be asked to log in with Connect-AzAccount.
50Alternatively, you (or a
51build pipeline) can pass $ProvisionerApplicationId and
52$ProvisionerApplicationSecret to authenticate a service principal with access to
53create resources.
54
55## EXAMPLES
56
57### EXAMPLE 1
58```
59Remove-TestResources.ps1 keyvault -Force
60Use the currently logged-in account to delete the resources created for Key Vault testing.
61```
62
63### EXAMPLE 2
64```
65Remove-TestResources.ps1 `
66 -ResourceGroupName "${env:AZURE_RESOURCEGROUP_NAME}" `
67 -TenantId '$(TenantId)' `
68 -ProvisionerApplicationId '$(AppId)' `
69 -ProvisionerApplicationSecret '$(AppSecret)' `
70 -Force `
71 -Verbose `
72When run in the context of an Azure DevOps pipeline, this script removes the
73resource group whose name is stored in the environment variable
74AZURE_RESOURCEGROUP_NAME.
75```
76
77## PARAMETERS
78
79### -BaseName
80A name to use in the resource group and passed to the ARM template as 'baseName'.
81This will delete the resource group named 'rg-\<baseName\>'
82
83```yaml
84Type: String
85Parameter Sets: Default
86Aliases:
87
88Required: False
89Position: Named
90Default value: None
91Accept pipeline input: False
92Accept wildcard characters: False
93```
94
95```yaml
96Type: String
97Parameter Sets: Default+Provisioner
98Aliases:
99
100Required: True
101Position: Named
102Default value: None
103Accept pipeline input: False
104Accept wildcard characters: False
105```
106
107### -ResourceGroupName
108The name of the resource group to delete.
109
110```yaml
111Type: String
112Parameter Sets: ResourceGroup+Provisioner, ResourceGroup
113Aliases:
114
115Required: True
116Position: Named
117Default value: None
118Accept pipeline input: False
119Accept wildcard characters: False
120```
121
122### -TenantId
123The tenant ID of a service principal when a provisioner is specified.
124
125```yaml
126Type: String
127Parameter Sets: Default+Provisioner, ResourceGroup+Provisioner
128Aliases:
129
130Required: True
131Position: Named
132Default value: None
133Accept pipeline input: False
134Accept wildcard characters: False
135```
136
137### -SubscriptionId
138Optional subscription ID to use when deleting resources when logging in as a
139provisioner.
140You can also use Set-AzContext if not provisioning.
141
142If you do not specify a SubscriptionId and are not logged in, one will be
143automatically selected for you by the Connect-AzAccount cmdlet.
144
145Once you are logged in (or were previously), the selected SubscriptionId
146will be used for subsequent operations that are specific to a subscription.
147
148```yaml
149Type: String
150Parameter Sets: (All)
151Aliases:
152
153Required: False
154Position: Named
155Default value: None
156Accept pipeline input: False
157Accept wildcard characters: False
158```
159
160### -ProvisionerApplicationId
161A service principal ID to provision test resources when a provisioner is specified.
162
163```yaml
164Type: String
165Parameter Sets: Default+Provisioner, ResourceGroup+Provisioner
166Aliases:
167
168Required: True
169Position: Named
170Default value: None
171Accept pipeline input: False
172Accept wildcard characters: False
173```
174
175### -ProvisionerApplicationSecret
176A service principal secret (password) to provision test resources when a provisioner is specified.
177
178```yaml
179Type: String
180Parameter Sets: Default+Provisioner, ResourceGroup+Provisioner
181Aliases:
182
183Required: True
184Position: Named
185Default value: None
186Accept pipeline input: False
187Accept wildcard characters: False
188```
189
190### -ServiceDirectory
191A directory under 'sdk' in the repository root - optionally with subdirectories
192specified - in which to discover pre removal script named 'remove-test-resources-pre.json'.
193
194```yaml
195Type: String
196Parameter Sets: Default
197Aliases:
198
199Required: True
200Position: 1
201Default value: None
202Accept pipeline input: False
203Accept wildcard characters: False
204```
205
206```yaml
207Type: String
208Parameter Sets: Default+Provisioner, ResourceGroup+Provisioner, ResourceGroup
209Aliases:
210
211Required: False
212Position: 1
213Default value: None
214Accept pipeline input: False
215Accept wildcard characters: False
216```
217
218### -Environment
219Name of the cloud environment.
220The default is the Azure Public Cloud
221('PublicCloud')
222
223```yaml
224Type: String
225Parameter Sets: (All)
226Aliases:
227
228Required: False
229Position: Named
230Default value: AzureCloud
231Accept pipeline input: False
232Accept wildcard characters: False
233```
234
235### -CI
236Run script in CI mode. Infers various environment variable names based on CI convention.
237
238### -Force
239Force removal of resource group without asking for user confirmation
240
241```yaml
242Type: SwitchParameter
243Parameter Sets: (All)
244Aliases:
245
246Required: False
247Position: Named
248Default value: False
249Accept pipeline input: False
250Accept wildcard characters: False
251```
252
253### -RemoveTestResourcesRemainingArguments
254Captures any arguments not declared here (no parameter errors)
255
256```yaml
257Type: Object
258Parameter Sets: (All)
259Aliases:
260
261Required: False
262Position: Named
263Default value: None
264Accept pipeline input: False
265Accept wildcard characters: False
266```
267
268### -WhatIf
269Shows what would happen if the cmdlet runs.
270The cmdlet is not run.
271
272```yaml
273Type: SwitchParameter
274Parameter Sets: (All)
275Aliases: wi
276
277Required: False
278Position: Named
279Default value: None
280Accept pipeline input: False
281Accept wildcard characters: False
282```
283
284### -Confirm
285Prompts you for confirmation before running the cmdlet.
286
287```yaml
288Type: SwitchParameter
289Parameter Sets: (All)
290Aliases: cf
291
292Required: False
293Position: Named
294Default value: None
295Accept pipeline input: False
296Accept wildcard characters: False
297```
298
299### CommonParameters
300This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
301
302## INPUTS
303
304## OUTPUTS
305
306## NOTES
307
308## RELATED LINKS
View as plain text