Azure Function App with PowerShell — Periodically Get Azure Service Health Events

- Service issues — Problems in the Azure services that affect you right now.

- Planned maintenance — Upcoming maintenance that can affect the availability of your services in the future.

- Health advisories — Changes in Azure services that require your attention. Examples include deprecation of Azure features or upgrade requirements (e.g upgrade to a supported PHP framework).

- Security advisories — Security related notifications or violations that may affect the availability of your Azure services.

Prerequisite Actions

- Remove the last line of ‘Az.*’ = ‘5.*’
- Replace it with 'Az.ResourceGraph' = '0.8.0' #The latest version
#The content should look like below
# This file enables modules to be automatically managed by the Functions service.
# See https://aka.ms/functionsmanageddependency for additional information.
#
@{
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
# To use the Az module in your function app, please uncomment the line below.
'Az.ResourceGraph' = '0.8.0'
}

Demonstration

# Input bindings are passed in via param block.
param($Timer)
# Get the current universal time in the default string format.
$currentUTCtime = (Get-Date).ToUniversalTime()
# The 'IsPastDue' property is 'true' when the current function invocation is later than scheduled.if ($Timer.IsPastDue)
{
Write-Host "PowerShell timer is running late!"
}
# Write an information log with the current time.
Write-Host "PowerShell timer trigger function ran! TIME: $currentUTCtime"
#Write the installed module "Az.ResourceGraph"
Get-Module -Name Az.ResourceGraph | Write-Output
#Write to host of the queries Azure service health events
Search-AzGraph -Query "servicehealthresources | where type == 'microsoft.resourcehealth/events' | project subscriptionId, Status=properties.Status, TrackingId=properties.TrackingId, EventType=properties.EventType, Title=properties.Title" | Write-Output

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store