What’s the best Azure option for running a PowerShell script daily?

0
2
Asked By MellowCedar42 On

I've been developing a PowerShell script that I'd like to run automatically once a day instead of launching it manually. Our organization is entirely hosted in Azure, so I'm considering either an Azure Automation runbook or an Azure Function. Which option is generally the better fit for a scheduled PowerShell script? The script currently uses credentials to access several REST APIs. Can either option securely retrieve those credentials from Azure Key Vault, ideally without storing secrets directly in the script?

4 Answers

Answered By NovaTrail_58 On

Both Azure Automation and Azure Functions can handle this. Functions tend to be more developer-oriented and are useful when the code needs to integrate with other services or respond to events. Automation runbooks are usually simpler for scheduled administrative scripts.

Answered By CopperLynx86 On

A container with a scheduled job is another flexible option, but it adds operational overhead. Containers are portable and powerful, though you’ll need to manage the runtime, scheduling, monitoring, and authentication yourself. For a once-daily PowerShell task, that is probably more complexity than necessary unless you already use containers.

Answered By QuietHarbor7 On

Azure Automation is probably the most straightforward choice for a PowerShell script that just needs to run on a schedule. Enable the Automation account’s system-assigned managed identity, grant it permission to read the required secrets from Key Vault, and retrieve them at runtime with Get-AzKeyVaultSecret.

Answered By BrightMango31 On

You may not need Key Vault for every API. For Azure resources and Microsoft Graph, the Automation account’s managed identity can often be granted the necessary roles or API permissions directly. The script can then authenticate with managed identity and obtain tokens without managing a separate client secret. For external APIs that require credentials, store those secrets in Key Vault and authorize the managed identity to read them.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.