Get alerted when your Azure Database for MySQL server is not accessible!!!

Published Dec 17 2020 07:46 PM 2,773 Views
Microsoft

This blog post focuses on how to use the combination of Azure Automation, Logic App, Sendgrid, and Webhook Azure services to send email notification alerts when your Azure Database for MySQL server status changes. 

 

If you are using data encryption with customer managed key in Azure Database for MySQL, if there is an issue with reading from the Azure Key vault, any permission issues, or if the key has expired, then the server goes into an inaccessible state. This is by design to avoid security violations. To detect these conditions and receive alerts when the server goes into an inaccessible state, run following command:

 

 

 

 

az mysql server show -g <ResourceGroupName>-n <servername>--query [fullyQualifiedDomainName,userVisibleState] -o json

 

 

 


The below solution uses 

• Azure Automation runbook to run and check the server status with the az modules
• Sendgrid to send the mail
• Webhook and Logic App to make the schedule to run every 15 mins

 

Step 1: Prepare your environment for Azure Automation runbook

  1. Create an Azure automation account  (How to link)
  2. Import the following module (How to link)
    1. Az.Accounts
    2. Az.Automation
    3. Az.MySql
  3. Create a SendGrid account (How to link)
    1. Select Manage and get the account name for the alias you used while creating the SendGrid account
    2. Go to Settings, select Accounts details, and then make a note of the Username.

      1.jpg

Step 2: Create a Runbook in the Azure Automation account

  1. From the portal, check the Azure automation account you have created.
  2. Select Runbooks and then select Create a Runbook.

    2.jpg

  3. Give the Name  and Runbook Type  (PowerShell)

    3.jpg

  4. Click on Create below
  5. Once created then select the runbook "Mysql_Server_Status" and click on Edit.
  6. Copy paste the following script and make the following changes with the data we have received. Click Save and Publish.
    Import-Module Az.Accounts
    Import-Module Az.Automation
    import-Module Az.MySql
    $connectionName = "AzureRunAsConnection"
    $EmailTo = "<Alias>@domain.com"
    $smtpServer = "smtp.sendgrid.net"
    $smtpFrom = "No-reply@azureadmin.com"
    $messageSubject = "The Azure Database for MySQL is not Available"
    try
    {
        # Get the connection "AzureRunAsConnection "
        $servicePrincipalConnection = Get-AutomationConnection -Name $connectionName       
        "Logging in to Azure..."
        Connect-AzAccount `
            -ServicePrincipal `
            -TenantId $servicePrincipalConnection.TenantId `
            -ApplicationId $servicePrincipalConnection.ApplicationId `
            -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint 
    }
    catch {
        if (!$servicePrincipalConnection)
        {
            $ErrorMessage = "Connection $connectionName not found."
            throw $ErrorMessage
        } else{
            Write-Error -Message $_.Exception
            throw $_.Exception
        }
    }
    #Get all Mysql resources status which are not in ready state
    $mysqlservers = Get-AzMysqlServer | Where-Object {$_.UserVisibleState -ne "Ready"}
    if ($mysqlservers.count -gt 0)
    {
    foreach ($mysqlserver in $mysqlservers)
        {    
            #Write-Output ($mysqlserver.Name + " Current state is : " +  $mysqlserver.UserVisibleState)
            $Body = $mysqlserver.Name + " Current state is : " +  $mysqlserver.UserVisibleState
            $message = New-Object System.Net.Mail.MailMessage
            $message.From="No-reply@azureadmin.com"
            $message.to.add($EmailTo)
            $message.Subject = $messageSubject
            $message.Body = $Body
            $message.IsBodyHTML = $false
            $smtp = New-Object Net.Mail.SmtpClient($smtpServer,"587")
            #Add your Sendgridusername and sendgridpassword here:
            $credentials=new-object system.net.networkcredential("username_xxxxxxxxxx@azure.com","P@ssw0rd")
            $smtp.credentials=$credentials.getcredential($smtpServer,587,"basic")
            $smtp.Send($message)
        } 
    }​
  7. If you are ok to do this check once in hour you can directly got to schedule for runbooks and skip Step 3 below.
    4.jpg

Step 3: Scheduling the runbook

Since the frequency we require is lesser than one hour which is now not available we will use webhooks and logic app to do it to achieve monitoring at the minutes granularity.

  1. On the overview please click on Add webhook

    5.jpg

  2. Select Create a Webhook

    6.jpg

  3. Give the Name and Make sure you copy the URL from the below and keep it . Expire date also you can set as per you need.

    7.jpg

  4. Click on Create
  5. Now go to Logic App from portal and click on ADD

    8.jpg

  6. Give the details and click on Review and Create

    9.jpg

  7. Once you go to the Logic app created you will see Logic Apps Designer , Select Recurrence

    10.jpg

  8. Select the interval as 15 Frequency in Minute and click on New step

    11.jpg

  9. Select the HTTP webhook

    12.jpg

  10. Select  Subscribe Method as POST and Subscribe  URI copy the URI you got while creating the webhook  (Step 3 , Section 3)

    13.jpg

Once you do this the Logic app will trigger the webhook and that will in-turn trigger the script to run every 15 mins and if there is any of the MySQL servers which are not in ready state, an e-mail notification will be triggered as shown below.

 

14.jpg

 

 

Hope this helps !!!

 

Sudheesh Narayanaswamy

%3CLINGO-SUB%20id%3D%22lingo-sub-1996368%22%20slang%3D%22en-US%22%3EGet%20alerted%20when%20your%20Azure%20Database%20for%20MySQL%20server%20is%20not%20accessible!!!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1996368%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20blog%20post%20focuses%20on%20how%20to%20use%20the%20combination%20of%20Azure%20Automation%2C%20Logic%20App%2C%20Sendgrid%2C%20and%20Webhook%20Azure%20services%20to%20send%20email%20notification%20alerts%20when%20your%20Azure%20Database%20for%20MySQL%20server%20status%20changes.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20using%20data%20encryption%20with%20customer%20managed%20key%20in%20Azure%20Database%20for%20MySQL%2C%20if%20there%20is%20an%20issue%20with%20reading%20from%20the%20Azure%20Key%20vault%2C%20any%20permission%20issues%2C%20or%20if%20the%20key%20has%20expired%2C%20then%20the%20server%20goes%20into%20an%20inaccessible%20state.%20This%20is%20by%20design%20to%20avoid%20security%20violations.%20To%20detect%20these%20conditions%20and%20receive%20alerts%20when%20the%20server%20goes%20into%20an%20inaccessible%20state%2C%20run%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Eaz%20mysql%20server%20show%20-g%20%3CRESOURCEGROUPNAME%3E-n%20%3CSERVERNAME%3E--query%20%5BfullyQualifiedDomainName%2CuserVisibleState%5D%20-o%20json%3C%2FSERVERNAME%3E%3C%2FRESOURCEGROUPNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EThe%20below%20solution%20uses%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22%20padding-left%20%3A%2030px%3B%20%22%3E%E2%80%A2%20Azure%20Automation%20runbook%20to%20run%20and%20check%20the%20server%20status%20with%20the%20az%20modules%3CBR%20%2F%3E%E2%80%A2%20Sendgrid%20to%20send%20the%20mail%3CBR%20%2F%3E%E2%80%A2%20Webhook%20and%20Logic%20App%20to%20make%20the%20schedule%20to%20run%20every%2015%20mins%3C%2FP%3E%0A%3CP%20style%3D%22%20padding-left%20%3A%2030px%3B%20%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1319076297%22%20id%3D%22toc-hId-1319076327%22%3EStep%201%3A%20Prepare%20your%20environment%20for%20Azure%20Automation%20runbook%3C%2FH3%3E%0A%3COL%20class%3D%22lia-list-style-type-lower-alpha%22%3E%0A%3CLI%3ECreate%20an%20Azure%20automation%20account%26nbsp%3B%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-create-standalone-account%23create-a-new-automation-account-in-the-azure-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHow%20to%20link%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EImport%20the%20following%20module%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-create-standalone-account%23create-a-new-automation-account-in-the-azure-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHow%20to%20link%3C%2FA%3E)%3COL%20class%3D%22lia-list-style-type-lower-alpha%22%3E%0A%3CLI%3EAz.Accounts%3C%2FLI%3E%0A%3CLI%3EAz.Automation%3C%2FLI%3E%0A%3CLI%3EAz.MySql%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20SendGrid%20account%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsendgrid-dotnet-how-to-send-email%23to-sign-up-for-a-sendgrid-account%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHow%20to%20link%3C%2FA%3E)%3COL%20class%3D%22lia-list-style-type-lower-roman%22%3E%0A%3CLI%3ESelect%26nbsp%3B%3CSTRONG%3EManage%3C%2FSTRONG%3E%20and%20get%20the%20account%20name%20for%20the%20alias%20you%20used%20while%20creating%20the%20SendGrid%20account%3C%2FLI%3E%0A%3CLI%3EGo%20to%20%3CSTRONG%3ESettings%3C%2FSTRONG%3E%2C%20select%20%3CSTRONG%3EAccounts%20details%3C%2FSTRONG%3E%2C%26nbsp%3Band%20then%20make%20a%20note%20of%20the%20%3CSTRONG%3EUsername%3C%2FSTRONG%3E.%3CSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%221.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241231iC6A7531BC7D41879%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%221.jpg%22%20alt%3D%221.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH3%20id%3D%22toc-hId--488378166%22%20id%3D%22toc-hId--488378136%22%3EStep%202%3A%20Create%20a%20Runbook%20in%20the%20Azure%20Automation%20account%3C%2FH3%3E%0A%3COL%20class%3D%22lia-list-style-type-lower-alpha%22%3E%0A%3CLI%3EFrom%20the%20portal%2C%20check%20the%20Azure%20automation%20account%20you%20have%20created.%3C%2FLI%3E%0A%3CLI%3ESelect%20%3CSTRONG%3ERunbooks%3C%2FSTRONG%3E%20and%20then%20select%20%3CSTRONG%3ECreate%20a%20Runbook%3C%2FSTRONG%3E.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241235i4A01531D429D84FC%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%222.jpg%22%20alt%3D%222.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EGive%20the%20%3CSTRONG%3EName%26nbsp%3B%3C%2FSTRONG%3E%20and%20%3CSTRONG%3ERunbook%20Type%26nbsp%3B%20(PowerShell)%3C%2FSTRONG%3E%3CSTRONG%20style%3D%22font-family%3A%20inherit%3B%22%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%223.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241232iF7B6550C6413FE6F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%223.jpg%22%20alt%3D%223.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3EClick%20on%20%3CSTRONG%3ECreate%3C%2FSTRONG%3E%20below%3C%2FLI%3E%0A%3CLI%3EOnce%20created%20then%20select%20the%20runbook%20%3CSTRONG%3E%22Mysql_Server_Status%22%3C%2FSTRONG%3E%20and%20click%20on%20%3CSTRONG%3EEdit.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3ECopy%20paste%20the%20following%20script%20and%20make%20the%20following%20changes%20with%20the%20data%20we%20have%20received.%20Click%20%3CSTRONG%3ESave%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EPublish.%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EImport-Module%26nbsp%3BAz.Accounts%0AImport-Module%26nbsp%3BAz.Automation%0Aimport-Module%26nbsp%3BAz.MySql%0A%24connectionName%26nbsp%3B%3D%26nbsp%3B%22AzureRunAsConnection%22%0A%24EmailTo%26nbsp%3B%3D%26nbsp%3B%22%3CALIAS%3E%40domain.com%22%0A%24smtpServer%26nbsp%3B%3D%26nbsp%3B%22smtp.sendgrid.net%22%0A%24smtpFrom%26nbsp%3B%3D%26nbsp%3B%22No-reply%40azureadmin.com%22%0A%24messageSubject%26nbsp%3B%3D%26nbsp%3B%22The%26nbsp%3BAzure%26nbsp%3BDatabase%26nbsp%3Bfor%26nbsp%3BMySQL%26nbsp%3Bis%26nbsp%3Bnot%26nbsp%3BAvailable%22%0Atry%0A%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%23%26nbsp%3BGet%26nbsp%3Bthe%26nbsp%3Bconnection%26nbsp%3B%22AzureRunAsConnection%26nbsp%3B%22%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24servicePrincipalConnection%26nbsp%3B%3D%26nbsp%3BGet-AutomationConnection%26nbsp%3B-Name%26nbsp%3B%24connectionName%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%22Logging%26nbsp%3Bin%26nbsp%3Bto%26nbsp%3BAzure...%22%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BConnect-AzAccount%26nbsp%3B%60%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B-ServicePrincipal%26nbsp%3B%60%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B-TenantId%26nbsp%3B%24servicePrincipalConnection.TenantId%26nbsp%3B%60%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B-ApplicationId%26nbsp%3B%24servicePrincipalConnection.ApplicationId%26nbsp%3B%60%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B-CertificateThumbprint%26nbsp%3B%24servicePrincipalConnection.CertificateThumbprint%26nbsp%3B%0A%7D%0Acatch%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bif%26nbsp%3B(!%24servicePrincipalConnection)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24ErrorMessage%26nbsp%3B%3D%26nbsp%3B%22Connection%26nbsp%3B%24connectionName%26nbsp%3Bnot%26nbsp%3Bfound.%22%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bthrow%26nbsp%3B%24ErrorMessage%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%26nbsp%3Belse%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BWrite-Error%26nbsp%3B-Message%26nbsp%3B%24_.Exception%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bthrow%26nbsp%3B%24_.Exception%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%0A%7D%0A%23Get%26nbsp%3Ball%26nbsp%3BMysql%26nbsp%3Bresources%26nbsp%3Bstatus%20which%20are%20not%20in%20ready%20state%0A%24mysqlservers%26nbsp%3B%3D%26nbsp%3BGet-AzMysqlServer%26nbsp%3B%7C%26nbsp%3BWhere-Object%26nbsp%3B%7B%24_.UserVisibleState%26nbsp%3B-ne%26nbsp%3B%22Ready%22%7D%0Aif%26nbsp%3B(%24mysqlservers.count%26nbsp%3B-gt%26nbsp%3B0)%0A%7B%0Aforeach%26nbsp%3B(%24mysqlserver%26nbsp%3Bin%26nbsp%3B%24mysqlservers)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%23Write-Output%26nbsp%3B(%24mysqlserver.Name%26nbsp%3B%2B%26nbsp%3B%22%26nbsp%3BCurrent%26nbsp%3Bstate%26nbsp%3Bis%26nbsp%3B%3A%26nbsp%3B%22%26nbsp%3B%2B%26nbsp%3B%26nbsp%3B%24mysqlserver.UserVisibleState)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24Body%26nbsp%3B%3D%26nbsp%3B%24mysqlserver.Name%26nbsp%3B%2B%26nbsp%3B%22%26nbsp%3BCurrent%26nbsp%3Bstate%26nbsp%3Bis%26nbsp%3B%3A%26nbsp%3B%22%26nbsp%3B%2B%26nbsp%3B%26nbsp%3B%24mysqlserver.UserVisibleState%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24message%26nbsp%3B%3D%26nbsp%3BNew-Object%26nbsp%3BSystem.Net.Mail.MailMessage%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24message.From%3D%22No-reply%40azureadmin.com%22%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24message.to.add(%24EmailTo)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24message.Subject%26nbsp%3B%3D%26nbsp%3B%24messageSubject%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24message.Body%26nbsp%3B%3D%26nbsp%3B%24Body%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24message.IsBodyHTML%26nbsp%3B%3D%26nbsp%3B%24false%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24smtp%26nbsp%3B%3D%26nbsp%3BNew-Object%26nbsp%3BNet.Mail.SmtpClient(%24smtpServer%2C%22587%22)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%23Add%26nbsp%3Byour%26nbsp%3BSendgridusername%26nbsp%3Band%26nbsp%3Bsendgridpassword%26nbsp%3Bhere%3A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24credentials%3Dnew-object%26nbsp%3Bsystem.net.networkcredential(%22username_xxxxxxxxxx%40azure.com%22%2C%22P%40ssw0rd%22)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24smtp.credentials%3D%24credentials.getcredential(%24smtpServer%2C587%2C%22basic%22)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%24smtp.Send(%24message)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%26nbsp%3B%0A%7D%E2%80%8B%3C%2FALIAS%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3CLI%3E%3CP%3EIf%20you%20are%20ok%20to%20do%20this%20check%20once%20in%20hour%20you%20can%20directly%20got%20to%20schedule%20for%20runbooks%20and%20skip%20Step%203%20below.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%224.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241233iB16E4D8A2C695A4D%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%224.jpg%22%20alt%3D%224.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH3%20id%3D%22toc-hId-1999134667%22%20id%3D%22toc-hId-1999134697%22%3EStep%203%3A%20Scheduling%20the%20runbook%3C%2FH3%3E%0A%3CP%3ESince%20the%20frequency%20we%20require%20is%20lesser%20than%20one%20hour%20which%20is%20now%20not%20available%20we%20will%20use%20webhooks%20and%20logic%20app%20to%20do%20it%20to%20achieve%20monitoring%20at%20the%20minutes%20granularity.%3C%2FP%3E%0A%3COL%20class%3D%22lia-list-style-type-lower-alpha%22%3E%0A%3CLI%3EOn%20the%20overview%20please%20click%20on%20%3CSTRONG%3EAdd%20webhook%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%225.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241234i63E3AD76086A31A3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%225.jpg%22%20alt%3D%225.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3ESelect%20%3CSTRONG%3ECreate%20a%20Webhook%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%226.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241236i47787E48BD7F5FD0%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%226.jpg%22%20alt%3D%226.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3E%3CP%3EGive%20the%20%3CSTRONG%3EName%20%3C%2FSTRONG%3Eand%20Make%20sure%20you%20copy%20the%20URL%20from%20the%20below%20and%20keep%20it%20.%20Expire%20date%20also%20you%20can%20set%20as%20per%20you%20need.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%227.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241238iB6D7BD0E505F94AC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%227.jpg%22%20alt%3D%227.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3EClick%20on%20%3CSTRONG%3ECreate%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3ENow%20go%20to%3CSTRONG%3E%20Logic%20App%20%3C%2FSTRONG%3Efrom%20portal%20and%20click%20on%20%3CSTRONG%3EADD%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%228.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241237iF80F54A3879F3F1A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%228.jpg%22%20alt%3D%228.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3CLI%3E%3CP%3EGive%20the%20details%20and%20click%20on%20%3CSTRONG%3EReview%20and%20Create%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%229.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241247iD76C59DC8564F9AF%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%229.jpg%22%20alt%3D%229.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EOnce%20you%20go%20to%20the%20Logic%20app%20created%20you%20will%20see%20Logic%20Apps%20Designer%20%2C%20Select%20Recurrence%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2210.jpg%22%20style%3D%22width%3A%20200px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241240iFE8C9F1C2E4390BE%2Fimage-size%2Fsmall%3Fv%3D1.0%26amp%3Bpx%3D200%22%20role%3D%22button%22%20title%3D%2210.jpg%22%20alt%3D%2210.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3ESelect%20the%20interval%20as%2015%20Frequency%20in%20Minute%20and%20click%20on%20%3CSTRONG%3ENew%20step%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2211.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241241i5A003D1936D4CC8A%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2211.jpg%22%20alt%3D%2211.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3ESelect%20the%20HTTP%20webhook%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2212.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241242iDA296A065D2A526E%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2212.jpg%22%20alt%3D%2212.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3ESelect%20%3CSTRONG%3E%26nbsp%3BSubscribe%20Method%3C%2FSTRONG%3E%20as%20POST%20and%20%3CSTRONG%3ESubscribe%3C%2FSTRONG%3E%26nbsp%3B%20%3CSTRONG%3EURI%3C%2FSTRONG%3E%20copy%20the%20URI%20you%20got%20while%20creating%20the%20webhook%26nbsp%3B%20(Step%203%20%2C%20Section%203)%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2213.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241243iF101F242BE324884%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2213.jpg%22%20alt%3D%2213.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EOnce%20you%20do%20this%20the%20Logic%20app%20will%20trigger%20the%20webhook%20and%20that%20will%20in-turn%20trigger%20the%20script%20to%20run%20every%2015%20mins%20and%20if%20there%20is%20any%20of%20the%20MySQL%20servers%20which%20are%20not%20in%20ready%20state%2C%20an%20e-mail%20notification%20will%20be%20triggered%20as%20shown%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2214.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241244i432227551DE2A611%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2214.jpg%22%20alt%3D%2214.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHope%20this%20helps%20!!!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESudheesh%20Narayanaswamy%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1996368%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2214.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241248iDCFCA428B0397512%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2214.jpg%22%20alt%3D%2214.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Jan 04 2021 01:00 PM
Updated by: