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

  • Az PowerShell/CLI
  • Other programming languages

Prerequisite Actions

  1. Create an Azure Function App by following the steps mentioned here. Please ensure to use “PowerShell” as your runtime stack
  2. Configure the environment to have Az.ResourceGraph PowerShell module installed. The reason for installed Az.ResourceGraph module is that we are leveraging Azure Resource Graph API to query the needed information. If you would like to know more how this is done, please check this site. The same could also be accomplished via REST API.
- 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 for additional information.
# For latest supported version, go to ''.
# To use the Az module in your function app, please uncomment the line below.
'Az.ResourceGraph' = '0.8.0'


# Input bindings are passed in via param block.
# 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




Learning new things about Kubernetes every day. Hopefully, the learning notes could help people on the same journey!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why Coding Should be Essential Knowledge for All: A Brief History of Programming.

Automate Network tasks like a pro w/ Windows Server 2019 & PowerShell

Some upgrades & patches coming to MVM & Xeno Infinity Verse

But if you believe in your worth and value your time, the hustle seems pointless

Enterprise Integration and Low Code Applications: A Practical Tutorial with MuleSoft Anypoint…

Complete Guide on Best Practices for Magento 2 Development

Modern way of requesting Permission in Android

Facebook’s Oculus Quest 2 Has Some Serious Privacy Issues

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


Learning new things about Kubernetes every day. Hopefully, the learning notes could help people on the same journey!

More from Medium

Introduction to the Azure IoT Products and an Overview of Azure IoT Hub.

How to Share Gallery VM images across Azure Tenants

How to: Area and Iteration organization charts on Azure DevOps

Missing traces/exceptions in Application Insights