Share via

Enable Azure Backup Alerts using powershell

Kalaimani Thirupathi 411 Reputation points
2020-12-30T14:11:52.707+00:00

Dear All,

Can you someone help me to enable the Azure Backup Alerts using Powershell, I have 300+ subscription which we need to enable the backup alerts for the Azure backup

Azure Monitor
Azure Monitor

An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.

Azure Backup
Azure Backup

An Azure backup service that provides built-in management at scale.


2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 132.1K Reputation points MVP Volunteer Moderator
    2020-12-30T18:18:18.533+00:00

    Use on your own risk!
    This script is not tested!

    Import-Module Az 
    $tenantId = '<your Azure Tenant ID>'
    $emailAddress = '******@test.org'
    Connect-AzAccount -Tenant $tenantId
    $subs = Get-AzSubscription
    Foreach ($sub in $subs)
        {
        select-AzSubscription $sub | Out-Null
        $subName = $sub.Name
        $rsvs = Get-AzRecoveryServicesVault
        foreach ($rsv in $rsvs)
            {
                $rsvName = $rsv.Name
                $rsvRg = $rsv.resourceGroupName
                Write-Host "Subscription = $subName`r`nRSVname = $rsvName`r`nRG = $rsvRG"
                Set-AzRecoveryServicesAsrVaultContext -Vault $rsv | Out-Null
                Set-AzRecoveryServicesAsrAlertSetting -CustomEmailAddress $emailAddress -LocaleID "en-us" -EnableEmailSubscriptionOwner | Out-Null
            }
        }
    

    After some more searching I found these two:
    https://techcommunity.microsoft.com/t5/azure/recovery-services-vault-backup-alerts-configure-notifications/m-p/1208466
    https://feedback.azure.com/forums/258995-azure-backup/suggestions/39877798-configure-notifications-for-backup-alerts-in-recov

    It might be that Azure Backup Alert Notifications can't be configured via PowerShell today.


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    Was this answer helpful?

    1 person found this answer helpful.

  2. Andreas Baumgarten 132.1K Reputation points MVP Volunteer Moderator
    2020-12-30T15:55:29.017+00:00

    The raw structure of the PowerShell script could look like this:

    1. Login to the Azure Tenant
    2. Get all Subscriptions
    3. For each Subscription get the Ressource Groups
    4. For each Resource Group check if a Recovery Service Vault exists
    5. If yes: Get the Recovery Service Vault and add the Alert Notification
    6. Next Ressource Group ...
    7. If done next Subscription ...

    Maybe it's possible to get it done easier, I haven't tried this:

    1. Login to Azure Tenant
    2. Get all Subscriptions
    3. For each Subscription get all Recovery Service Vaults
    4. For each Recovery Service Vault add the Alert Notification
    5. Next Subscription

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.