Few days ago, I was working with one of my customer. I advised him to host his O365 scripts in Azure instead using a local server. In this post, I would like to share why I recommended this to my customer and what solutions we've identified for hosting PowerShell script in Azure.
Why in my opinion, Azure is the best companion for executing O365 PowerShell scripts (or code)?
First, Azure services SLAs guarantee that your script will run 99.9xxx% of times. Usually, it's hard to provide such level of services on a local server. It may require a big investment for few scripts execution time mostly without any SLA and without service guarantee. You may also need, to open some ports, to configure a proxy, to harden your server security, to configure some antivirus, and to maintain your local server. In Azure, most services allow you to only focus on your PowerShell script because all the infrastructure, the SLAs and security is taken care by Microsoft. You only pay for what you consume in Azure. Some services presented below might be less expensive than running a local server which is consuming power supply all day long. To finish, when hosting your scripts in Azure may rely on all other Azure services (SQL, Big Data, Data Factory etc) and get some flexibility for any scripts improvements or complexity.
Services in Azure for hosting and executing PowerShell
- Via a Azure VM :
- Overview: https://azure.microsoft.com/en-us/services/virtual-machines/
- Pricing: https://azure.microsoft.com/en-us/pricing/details/virtual-machines/windows/
- Usage : I recommend to only use this solution for migration project or script development.
- Via Azure Function App :
- Overview: https://azure.microsoft.com/en-us/services/functions/
- Pricing: https://azure.microsoft.com/en-us/pricing/details/functions/
- You may rely on the below procedure to create une Azure Function running PowerShell :
- Note: PowerShell language is experimental in Azure Function. That's why I do not recommend this services for production use yet.
- Via Azure Automation account (recommended solution):
- Via Azure Web Jobs (in Azure App Services) :
- Overview: https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
- Pricing: https://azure.microsoft.com/en-us/pricing/details/app-service/windows/
- Procedure : Exécuter des tâches en arrière-plan avec WebJobs dans Azure App Service - en-ushttps://docs.microsoft.com/fr-fr/azure/app-service/web-sites-create-web-jobs