Spoiler: I am new to Azure and Azure Powershell.
I started to learn Azure and Azure Powershell and my current self-given excercise was to write a script, which checks if a specifig resource group exist in Azure. If this specific resource group does not exist, then create one. So I started to write this script:
# Exit on error
$ErrorActionPreference = "Stop"
# Import module for Azure Rm
Import-Module AzureRM
# Connect with Azure
Connect-AzureRmAccount
# Define name of Resource group we want to create
$ResourceGroupTest = "ResourceGroupForStorageAccount"
# Check if ResourceGroup exists
Get-AzureRmResourceGroup -Name $ResourceGroupTest -ErrorVariable $NotPresent -ErrorAction SilentlyContinue
Write-Host "Start to check if Resource group '$($ResourceGroupTest)' exists..."
if ($NotPresent) {
Write-Host "Resource group with name '$($ResourceGroupTest)' does not exist."
# Create resource group
New-AzureRmResourceGroup -Name $ResourceGroupTest -Location "West Europe" -Verbose
} else {
Write-Host "Found Resource group with name '$($ResourceGroupTest)'."
}
Now, when I run this script, I get this sort of output:
Start to check if Resource group 'ResourceGroupForStorageAccount' exists...
Found Resource group with name 'ResourceGroupForStorageAccount'.
Account SubscriptionName Tenant ...
------- ---------------- -------- ...
[email protected] Some subscription ...
But I cannot find this newly created resource group with name ResourceGroupForStorageAccount in the list of resource groups in the Azure RM portal.
Where is my problem?