person s gray hoodie
Photo by Sebastiaan Stam on Pexels.com

Azure Application Proxy is one of the great development have been made so far but I have seen Azure AD Proxy becomes ‘Inactive‘ and creates issue to end users. When it becomes inactive azure as proxy, shouldn’t use that connector for sending traffic but that’s not the case and I have noticed it several times.

Hence I thought to collect performance monitoring values as well as have a script which can find Azure AD Proxy Connector Status from Azure so that we can take corrective action to avoid any end user issue.

Before we proceed further we would have to Install AzureAD Powershell on a computer which will make connections to Azure for monitoring.

Pre-requisites of running this script :- 

  • Global Administrator credentials.
  • Install AzureAD Powershell.

Download this script and run it manually first, once you are sure that you get the value as desired then schedule it.

<# Monitor Azure AD Proxy
Author - Sourabh Kumar Jha
Date - 03/28/2019
Change value of these AdminUsername, AdminPassword, emailFrom, emailTo and smtpServer
#&gt;

# Import Azure AD Module
Import-Module AzureAD

# Provide Office 365 Credentials

$AdminUsername = "Office365AdminAccount"
$AdminPassword = "credentials"
$SecurePassword = ConvertTo-SecureString $AdminPassword -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $AdminUsername,$SecurePassword
Connect-AzureAD -Credential $cred

# Get the current State of App Proxy Connector
$service = Get-AzureADApplicationProxyConnector

# Throw alert if status is inactive
if ($service.status -eq "inactive")

# Send email if Status is inactive.
{
$emailFrom = "AzureADProxy@xyz.com"
$emailTo = "recipeintemail@xyz.com"
$subject = "Action Required - Azure AD Proxy Connector - InActive"
$body = $service + 
"Restart ApplicationProxyConnectorService Service, You might have to kill the ApplicationProxyConnectorService process and start the service"
$smtpServer = "smtpserverfqdn"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
}

# Disconnect Azure AD Module
Disconnect-AzureAD

Thank you for reading !

Advertisements