Confused browser cloud being redirected away from the wrong building to the right one, with a stopwatch

Azure Portal Keeps Redirecting to Wrong Tenant? Fix It in 30 Seconds

The Problem Ever tried logging into your personal Azure account only to get redirected to your company tenant over and over again? Even after clearing cookies, trying incognito mode, and switching browsers, the redirect persists like a stubborn bug. This happens because Azure remembers your email domain and automatically associates it with a business tenant—even when you have a personal account with the same domain. I recently ran into this exact issue when setting up a new Azure account, and after some experimenting, I found a bulletproof solution. ...

June 16, 2025 · 2 min · thomasf
windows-powershell-ise-icon

PRTG Monitor Azure Backups

I adapted an existing solution from 2azure.nl for monitoring Azure Backup status through PRTG in our environment. I did some refactoring and I like to share the code with you. Run the script in PRTG with these parameters: -Password "XXXXX" -applicationid "XXXXX" -TenantId "XXXXX" -VaultName "XXXXX" -ResourceGroupName "XXXXX" The complete script is available in the code block below." param( [Parameter(Mandatory = $true)] [string]$Password, [Parameter(Mandatory = $true)] [string]$ApplicationId, [Parameter(Mandatory = $true)] [string]$TenantId, [Parameter(Mandatory = $true)] [string]$VaultName, [Parameter(Mandatory = $true)] [string]$ResourceGroupName ) # Run Once: Install required modules # Install-Module -Name Az.Accounts # Install-Module -Name Az.RecoveryServices Import-Module Az.Accounts Import-Module Az.RecoveryServices # Login $securePassword = ConvertTo-SecureString $Password -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential($ApplicationId, $securePassword) Connect-AzAccount -Credential $credential -ServicePrincipal -TenantId $TenantId | Out-Null # Access specific vault $vault = Get-AzRecoveryServicesVault -Name $VaultName -ResourceGroupName $ResourceGroupName if ($vault) { # Set vault context $vault | Set-AzRecoveryServicesVaultContext # Check backups last 24 hours, only Backup operations $jobs = Get-AzRecoveryServicesBackupJob -From (Get-Date).AddDays(-1).ToUniversalTime() | Where-Object { $_.Operation -eq "Backup" } | Select-Object Status, WorkloadName $completed = ($jobs | Where-Object {$_.Status -eq 'Completed'}).Count $failed = ($jobs | Where-Object {$_.Status -eq 'Failed'}).Count $running = ($jobs | Where-Object {$_.Status -eq 'InProgress'}).Count # Get unique workload names $workloadNames = ($jobs | Select-Object -ExpandProperty WorkloadName -Unique) -join ', ' # Output for PRTG if ($failed -eq 0 -and $completed -gt 0) { $result = "<prtg> <result> <channel>Completed jobs</channel> <value>$completed</value> <LimitMode>1</LimitMode> <LimitMinError>1</LimitMinError> <LimitErrorMsg>No completed backups found!</LimitErrorMsg> </result> <result> <channel>Failed jobs</channel> <value>$failed</value> <LimitMode>1</LimitMode> <LimitMaxError>0</LimitMaxError> <LimitErrorMsg>Failed backup jobs detected!</LimitErrorMsg> </result> <result> <channel>Running jobs</channel> <value>$running</value> <LimitMode>1</LimitMode> <LimitMaxWarning>1</LimitMaxWarning> <LimitMaxError>2</LimitMaxError> <LimitWarningMsg>Multiple backup jobs running</LimitWarningMsg> <LimitErrorMsg>Too many backup jobs running!</LimitErrorMsg> </result> <text>Backup successful in vault: $($vault.Name) for workloads: $workloadNames</text> </prtg>" } else { $result = "<prtg> <error>1</error> <text>Backup failed in vault: $($vault.Name), failed jobs: $failed, workloads: $workloadNames</text> </prtg>" } } else { $result = "<prtg> <error>1</error> <text>Could not find vault $VaultName in resource group $ResourceGroupName</text> </prtg>" } Write-Host $result

January 5, 2025 · 2 min · thomasf
Shell

Create Azure Linux VM with worpress pre-installed

This is my first completed automated Linux Azure VM deployment. I like to share it with you. There are 3 parts Create a keygen for ssh Powershell script Bash script First start powershell and create a keypair with passphase ssh-keygen -m PEM -t rsa -b 4096 Then place the bash script somewhere on your local computer #! /bin/bash apt-get update apt-get install -y wordpress php libapache2-mod-php mysql-server php-mysql echo "Alias /blog /usr/share/wordpress" >>/etc/apache2/sites-available/wordpress.conf echo "" >>/etc/apache2/sites-available/wordpress.conf echo " Options FollowSymLinks" >>/etc/apache2/sites-available/wordpress.conf echo " AllowOverride Limit Options FileInfo" >>/etc/apache2/sites-available/wordpress.conf echo " DirectoryIndex index.php" >>/etc/apache2/sites-available/wordpress.conf echo " Order allow,deny" >>/etc/apache2/sites-available/wordpress.conf echo " Allow from all" >>/etc/apache2/sites-available/wordpress.conf echo "" >>/etc/apache2/sites-available/wordpress.conf echo "" >>/etc/apache2/sites-available/wordpress.conf echo " Options FollowSymLinks" >>/etc/apache2/sites-available/wordpress.conf echo " Order allow,deny" >>/etc/apache2/sites-available/wordpress.conf echo " Allow from all" >>/etc/apache2/sites-available/wordpress.conf echo "" >>/etc/apache2/sites-available/wordpress.conf a2ensite wordpress a2enmod rewrite reload apache2 service apache2 reload systemctl restart apache2 mysql -e "CREATE DATABASE wordpress;" mysql -e "CREATE USER wordpress@localhost IDENTIFIED BY 'Secret@Pass1';" mysql -e "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost;" mysql -e "FLUSH PRIVILEGES;" echo ">/etc/wordpress/config-localhost.php echo "define('DB_NAME', 'wordpress');">>/etc/wordpress/config-localhost.php echo "define('DB_USER', 'wordpress');">>/etc/wordpress/config-localhost.php echo "define('DB_PASSWORD', 'Secret@Pass1');">>/etc/wordpress/config-localhost.php echo "define('DB_HOST', 'localhost');">>/etc/wordpress/config-localhost.php echo "define('DB_COLLATE', 'utf8_general_ci');">>/etc/wordpress/config-localhost.php echo "define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');">>/etc/wordpress/config-localhost.php echo "?>">>/etc/wordpress/config-localhost.php service mysql start publicip=$(dig +short myip.opendns.com @resolver1.opendns.com) && mv /etc/wordpress/config-localhost.php /etc/wordpress/config-$publicip.php Then put the code in the Powershell ISE, change some variables and kickoff the script. ...

February 6, 2021 · 3 min · thomasf