Automate the Creation of an Azure Function with an Event Grid Subscription in PowerShell

My colleague, Sangita Bhor, was recently working on a case where we needed to automate the deployment of an Azure Function and Event Grid Subscription. The difficulty here is that there isn’t an API from functions to get the web hook needed on the Event Grid Subscription side. The script below shows you how to get the get the Master Key for the function, then the System Key, and finally create the Event Grid resource with the function app web hook. Full credit goes to Sangita for creating the whole script.