Azure | Get Notified when Break Glass account is used

Header break glass get to the cloud
Reading Time: 5 minutes

So to make sure that you can login to your Azure tenant, it is recommended to create at least TWO break glass accounts. These accounts are normally NOT used but in case of emergency and you cannot access your tenant, you have a backdoor.

What is a Break Glass Account?

A Break Glass Account is a special account created for emergency situations when the usual account credentials are unavailable. These accounts provide authorization to access critical resources, helping organisations to prevent service interruptions. This account should be used only as a last resort and should be strictly controlled to prevent misuse. The importance of Break Glass Accounts lies in their ability to ensure business continuity during critical events. Imagine being locked out of your account during an emergency, having a Break Glass Account can provide lifesaving access to critical systems and resources. Additionally, they enable a response strategy for security incidents, allowing organisations to quickly and efficiently respond to possible cybersecurity threats.

There are two types of Break Glass Accounts:

  • Shared Accounts
    Shared accounts are ideal for scenarios where multiple people might require urgent access. This account type can have multiple administrators, and its use must be tracked and audited to avoid security risks.
  • Privileged Accounts
    Privileged accounts are designed to be used by personnel who require elevated access to systems or applications. This account type should be limited to only the necessary personnel, and its use should be closely monitored.

In this blog post we are going to create two Shared Break Glass Accounts, having one is good, two is better.

Create Break Glass Accounts

You can choose two existing accounts in your Azure Active Directory for this or just create two new accounts. Below a PowerShell to create two new accounts.

 # install module and import module
Install-Module AzureAD -Force
Import-Module AzureAD -UseWindowsPowerShell

# connect to AzureAd
Connect-AzureAd

Now connection is made

$BreakGlass1Name = "Emergency Account 1"
$BreakGlass1Username = "LetMein"
$BreakGlass2Name = "Emergency Account 2"
$BreakGlass2Username = "EmergencyAccount"

# password generator
function Get-RandomCharacters($length, $characters) {
    $random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }
    $private:ofs = ""
    return [String]$characters[$random]
}
function Scramble-String([string]$inputString) {     
    $characterArray = $inputString.ToCharArray()   
    $scrambledStringArray = $characterArray | Get-Random -Count $characterArray.Length     
    $outputString = -join $scrambledStringArray
    return $outputString 
}

# creating passwords
$password = Get-RandomCharacters -length 20 -characters 'abcdefghiklmnoprstuvwxyz'
$password += Get-RandomCharacters -length 4 -characters 'ABCDEFGHKLMNOPRSTUVWXYZ'
$password += Get-RandomCharacters -length 2 -characters '1234567890'
$password += Get-RandomCharacters -Length 3 -characters '!@#$'
$BreakGlass1password = Scramble-String $password

$password = $null
$password = Get-RandomCharacters -length 20 -characters 'abcdefghiklmnoprstuvwxyz'
$password += Get-RandomCharacters -length 4 -characters 'ABCDEFGHKLMNOPRSTUVWXYZ'
$password += Get-RandomCharacters -length 2 -characters '1234567890'
$password += Get-RandomCharacters -Length 3 -characters '!@#$'
$BreakGlass2password = Scramble-String $password

# getting the .onmicrosoft.com address
$upnSuffix = (Get-AzureAdDomain | Where-Object {$_.IsInitial -eq $true}).Name

# creating break glass 1 user
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = $BreakGlass1password
New-AzureADUser -DisplayName $BreakGlass1Name -PasswordProfile $PasswordProfile -UserPrincipalName  $($BreakGlass1Username + "@" + $UpnSuffix) -AccountEnabled $true -MailNickName $BreakGlass1Username | Out-Null

# creating break glass 2 user
$PasswordProfile = $null
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = $BreakGlass2password
New-AzureADUser -DisplayName $BreakGlass2Name -PasswordProfile $PasswordProfile -UserPrincipalName  $($BreakGlass2Username + "@" + $UpnSuffix) -AccountEnabled $true -MailNickName $BreakGlass2Username | Out-Null

# adding break glass 1 user to Global Administrators
$roleDefinition = Get-AzureADMSRoleDefinition -Filter "displayName eq 'Global Administrator'"
$user = Get-AzureADUser -Filter "userPrincipalName eq '$($BreakGlass1Username + "@" + $UpnSuffix)'"
$roleAssignment = New-AzureADMSRoleAssignment -DirectoryScopeId '/' -RoleDefinitionId $roleDefinition.Id -PrincipalId $user.objectId

# adding break glass 2 user to Global Administrators
$user = Get-AzureADUser -Filter "userPrincipalName eq '$($BreakGlass2Username + "@" + $UpnSuffix)'"
$roleAssignment = New-AzureADMSRoleAssignment -DirectoryScopeId '/' -RoleDefinitionId $roleDefinition.Id -PrincipalId $user.objectId

# outputting to console the username and password
Write-Host "User $($BreakGlass1Username + "@" + $UpnSuffix) is created with password: $Breakglass1password "
Write-Host "User $($BreakGlass2Username + "@" + $UpnSuffix) is created with password: $Breakglass2password "

There will be two accounts being created called: Letmein and EmergencyAccount
Both accounts will be added to the Global Administrator role.
The passwords will be auto generated with a function. It will contain:

  • 20 low characters
  • 4 capital charaters
  • 2 numbers
  • 3 special characters

These passwords will be provided in the console during creation. Write them down and place them in a volt or on a post-it to the monitor (just have some fun 😉 )

Monitoring the use of Break Glass accounts

For the monitoring we use LogAnalytics and Azure Monitor. This will monitor the sign-in and notify the designated administrator.

Frist we need to create a Log Analytics Workspace (link)

Browse now to Microsoft Entra -> Azure Active Directory -> Monitoring & Health -> Diagnostic Settings -> Add diagnostic setting

Select AuditLogs and SignInLogs
Select Send to Log Analytics workspace and select the subscription and created Log Analytics workspace earlier.

Browse now to the All Users tab to find your Break Glass accounts and obtain the ObjectId. We need these to use in the monitor.

Get the ObjectId for both accounts and write them down in a notepad or other note.

Browse now to Azure Portal and select your created Log Analytics workspace

Create a new Alert Rule

image-6

Select Custom log Search at the first tab with Signal name
To get the needed information we need to provide the ObjectId’s from the Emergency accounts.

// Search for multiple Object IDs (UserIds)
SigninLogs
| project UserId
| where UserId == "EMERGENCYACCOUNT 1" or UserId == "EMERGENCYACCOUNT 2"

With the Alert Logic part we choose

  • Operator: Greater than
  • Theshold value: 0
  • Frequency of evaluation: 5 minute

At the next tab Actions, we need to create a new Action Group. Provide it with a name and continue to Notifications.

image-7

Select Email/SMS message/Push/Voice and provide an email and a telephone number to receive the sms after this you can Review + create

The next tab will be Details

Provide a name and set Severity to 0-Critical

Now you are all set to receive notifications when someone tries to login with the Emergency Break Glass accounts to your tenant.

When you test it, you will receive a sms message looking like this:

The SMS is received from Microsoft and notify you that there was an alert in the sign-ins with the break glass accounts.

Share and Enjoy !

Shares
Designer (23)

Stay close to the action—follow GetToThe.Cloud across social!
Deep dives and hands‑on how‑tos on Azure Local, hybrid cloud, automation, PowerShell/Bicep, AVD + FSLogix, image pipelines, monitoring, networking, and resilient design when the internet/Azure is down.

🔗 Our channels
▶️ YouTube: https://www.youtube.com/channel/UCa33PgGdXt-Dr4w3Ub9hrdQ
💼 LinkedIn Group: https://www.linkedin.com/groups/9181126/
✖️ X (Twitter): https://x.com/Gettothecloud
🎵 TikTok: https://www.tiktok.com/@gettothecloud
🐙 GitHub: https://github.com/GetToThe-Cloud/Website
💬 Slack: DM us for an invite
📲 WhatsApp: DM for the community link

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners. View more
Cookies settings
Accept
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Who we are

Our website address is: https://www.gettothe.cloud

Comments

When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year. If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser. When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed. If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue. For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where we send your data

Visitor comments may be checked through an automated spam detection service.
Save settings
Cookies settings