-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b5b36f
commit d6ac6e4
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
workload/bicep/modules/avdSessionHosts/.bicep/cleanUpRgDeployments.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// ========== // | ||
// Parameters // | ||
// ========== // | ||
|
||
@sys.description('Extension deployment name.') | ||
param name string | ||
|
||
@sys.description('Location where to deploy compute services.') | ||
param location string | ||
|
||
@sys.description('URI for clean up configuration script.') | ||
param baseScriptUri string | ||
|
||
@sys.description('Clean up script file name.') | ||
param file string | ||
|
||
@sys.description('Configuration arguments for clean up script.') | ||
param cleanUpScriptArguments string | ||
|
||
// =========== // | ||
// Deployments // | ||
// =========== // | ||
|
||
// Clean up RG deployments. | ||
resource fslogixConfigure 'Microsoft.Compute/virtualMachines/extensions@2022-08-01' = { | ||
name: '${name}/DeploymentCleanUp' | ||
location: location | ||
properties: { | ||
publisher: 'Microsoft.Compute' | ||
type: 'CustomScriptExtension' | ||
typeHandlerVersion: '1.10' | ||
autoUpgradeMinorVersion: true | ||
settings: {} | ||
protectedSettings: { | ||
fileUris: array(baseScriptUri) | ||
commandToExecute: 'powershell -ExecutionPolicy Unrestricted -File ${file} ${cleanUpScriptArguments}' | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
############################################################## | ||
# Clean up resource group deployments | ||
############################################################## | ||
|
||
[CmdletBinding(SupportsShouldProcess)] | ||
param( | ||
[Parameter(Mandatory)] | ||
[string]$subscriptionId, | ||
|
||
[Parameter(Mandatory)] | ||
[string]$resourceGroupName | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
# Select subscription | ||
Write-Output "Selecting subscription Subscription $subscriptionId." | ||
Select-AzSubscription -subscriptionid $subscriptionId | ||
|
||
# Get resource group succeeded deployments | ||
Write-Output "Getting $resourceGroupName succeeded deployments" | ||
$resourceGroupDeployments = Get-AzResourceGroupDeployment -ResourceGroupName rg-avd-m002-dev-usw3-pool-compute | Where-Object ProvisioningState -EQ 'Succeeded' | ||
|
||
# Delete resource group deployments | ||
Write-Output "Deleting succeded deployments on $resourceGroupName" | ||
foreach ($resourceGroupDeployment in $resourceGroupDeployments) { | ||
Remove-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -Name $resourceGroupDeployment.DeploymentName | ||
} |