mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Merge pull request #1144 from anosov1960/master
Changed remove resource to async
This commit is contained in:
+1
@@ -108,6 +108,7 @@ Update-AzConfig -DisplayBreakingChangeWarning $false
|
||||
|
||||
# Load required modules
|
||||
$requiredModules = @(
|
||||
"AzureAD",
|
||||
"Az.Accounts",
|
||||
"Az.ConnectedMachine",
|
||||
"Az.ResourceGraph"
|
||||
|
||||
+4
-4
@@ -84,10 +84,10 @@ This option is recommended because Cloud shell has the Azure PowerShell modules
|
||||
curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/uninstall-azure-extension-for-sql-server/uninstall-azure-extension-for-sql-server.ps1 -o uninstall-azure-extension-for-sql-server.ps1
|
||||
```
|
||||
|
||||
1. Run the script.
|
||||
1. Run the script using the desired scope. For example:
|
||||
|
||||
```console
|
||||
.\uninstall-azure-extension-for-sql-server.ps1 -SubId ALL
|
||||
.\uninstall-azure-extension-for-sql-server.ps1 -SubId <sub_id>
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
@@ -124,8 +124,8 @@ Use the following steps to run the script in a PowerShell session on your PC.
|
||||
Connect-AzAccount -TenantID (Get-AzureADTenantDetail).ObjectId
|
||||
```
|
||||
|
||||
1. Run the script using the desired scope.
|
||||
1. Run the script using the desired scope. For example:
|
||||
|
||||
```console
|
||||
.\uninstall-azure-extension-for-sql-server.ps1 -All $True
|
||||
.\uninstall-azure-extension-for-sql-server.ps1 -SubId <sub_id> -ResourceGroup <resource_group>
|
||||
```
|
||||
|
||||
+4
-3
@@ -88,7 +88,7 @@ foreach ($sub in $subscriptions){
|
||||
try {
|
||||
Set-AzContext -SubscriptionId $sub.Id
|
||||
}catch {
|
||||
write-host "[Environment]::NewLine + Invalid subscription: $($sub.Id)"
|
||||
write-host ([Environment]::NewLine + "Invalid subscription: $($sub.Id)")
|
||||
{continue}
|
||||
}
|
||||
|
||||
@@ -142,8 +142,9 @@ foreach ($sub in $subscriptions){
|
||||
$resources = Search-AzGraph -Query "$($query2)"
|
||||
|
||||
foreach ($r in $resources) {
|
||||
|
||||
Remove-AzResource -ResourceId $r.resourceId -Force | Out-Null
|
||||
|
||||
$job = Remove-AzResource -ResourceId $r.resourceId -Force -AsJob | Out-Null
|
||||
write-host ([Environment]::NewLine + "Removing resource: $($r.resourceId)")
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user