You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: eng/common/scripts/Helpers/Resource-Helpers.ps1
+73-4Lines changed: 73 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,32 @@ function Get-PurgeableGroupResources {
38
38
$purgeableResources+=$deletedKeyVaults
39
39
}
40
40
41
+
Write-Verbose"Retrieving AI resources from resource group $ResourceGroupName"
42
+
43
+
# Get AI resources that will go into soft-deleted state when the resource group is deleted
44
+
$subscriptionId= (Get-AzContext).Subscription.Id
45
+
$aiResources=@()
46
+
47
+
# Get active Cognitive Services accounts from the resource group
48
+
$response=Invoke-AzRestMethod-Method GET -Path "/subscriptions/$subscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.CognitiveServices/accounts?api-version=2024-10-01"-ErrorAction Ignore
49
+
if ($response.StatusCode-ge200-and$response.StatusCode-lt300-and$response.Content) {
Write-Verbose"Found $($aiResources.Count) AI resources to potentially purge after resource group deletion."
64
+
$purgeableResources+=$aiResources
65
+
}
66
+
41
67
return$purgeableResources
42
68
}
43
69
@@ -94,6 +120,29 @@ function Get-PurgeableResources {
94
120
}
95
121
catch { }
96
122
123
+
Write-Verbose"Retrieving deleted Cognitive Services accounts from subscription $subscriptionId"
124
+
125
+
# Get deleted Cognitive Services accounts for the current subscription.
126
+
$response=Invoke-AzRestMethod-Method GET -Path "/subscriptions/$subscriptionId/providers/Microsoft.CognitiveServices/deletedAccounts?api-version=2024-10-01"-ErrorAction Ignore
127
+
if ($response.StatusCode-ge200-and$response.StatusCode-lt300-and$response.Content) {
if ($response.StatusCode-ge200-and$response.StatusCode-lt300) {
146
-
Write-Warning"Successfully requested that Managed HSM '$($r.Name)' be purged, but may take a few minutes before it is actually purged."
199
+
Write-Verbose"Successfully requested that Managed HSM '$($r.Name)' be purged, but may take a few minutes before it is actually purged."-Verbose:$verboseFlag
Write-Warning"Failed purging $($r.AzsdkResourceType) '$($r.Name)' with status code $($response.StatusCode)."
223
+
}
224
+
}.GetNewClosure()
225
+
}
226
+
158
227
default {
159
228
Write-Warning"Cannot purge $($r.AzsdkResourceType) '$($r.AzsdkName)'. Add support to https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/scripts/Helpers/Resource-Helpers.ps1."
0 commit comments