-
Notifications
You must be signed in to change notification settings - Fork 1
/
resourceAvailabilityChecker.ps1
29 lines (28 loc) · 1.36 KB
/
resourceAvailabilityChecker.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$locations="eastus","westus2"
#$dateTimeStamp = $(Get-Date -Format "dd-MM-yyyy" )
#$logLocationInput = $(Get-Location)
#$logLocation = New-Item -Path $logLocationInput -Name "testlog-$dateTimeStamp.log" -ItemType "file" -Value ""
foreach ($i in $locations){
$randomIdentifier=$(Get-Random)
write-output "Location: $i"
write-output ""
$resourceGroupName="rsg-$i-$randomIdentifier"
write-output "Resource Group Name: $resourceGroupName"
write-output ""
az group create --name $resourceGroupName --location $i
write-output "Deploying CosmosDb - cosmosdb-$i-$randomIdentifier"
write-output ""
az cosmosdb create --name cosmosdb-$i-$randomIdentifier --resource-group $resourceGroupName
#$cosmosDbCreate=$(az cosmosdb create --name cosmosdb-$i-$randomIdentifier --resource-group $resourceGroupName)
<# if (!$cosmosDbCreate) {
Write-Error "Error creating CosmosDB account in region $i - cosmosdb-$i-$randomIdentifier"
return #>
# Start-Sleep -Seconds 30
# delete resources
write-output "Deleting CosmosDb - cosmosdb-$i-$randomIdentifier"
write-output ""
az cosmosdb delete --name "cosmosdb-$i-$randomIdentifier" --resource-group $resourceGroupName
write-output "Deleting Resource Group - $resourceGroupName"
write-output ""
az group delete -n $resourceGroupName
}