Is there a 'concurrent execution' option in Azure Automate Powershell Runbooks? - azure

I am working on automating maintenance tasks for a few thousand Azure SQL DBs via Azure Automate. I do not want to be limited to sequential execution since it will take too much time.
Is there a solution to run Azure Automate runbooks concurrently with Powershell?
Note: Creating dozens of runbooks running simultaneously is not ideal if concurrency is possible.

I believe the parent child approach along with foreach parallel construct in PowerShell workflow that is explained here should probably help you.

Related

How do I automate the removal of DCR Associations on problem VMs?

I have a couple of VMs that send more than several million events to their log analytics workspaces in a matter of days which runs up the cost of monitoring them exponentially.
I have the AMA setup on these VMs using a few DCRs.
Is there a way I can automatically remove the DCR association on any of my VMs that produce too many events within a certain time range?
You can use the powershell command: Remove-AzDataCollectionRule
See: https://learn.microsoft.com/en-us/powershell/module/az.monitor/remove-azdatacollectionrule?view=azps-8.1.0
If you want to automate it. You can run the powershell command from a runbook: https://learn.microsoft.com/en-us/azure/automation/automation-runbook-execution
You will need to create an alert that will trigger the execution of the runbook.

Stopping VMs in Azure when CPU usage is lower than 10%

Is there a way to script something using runbooks in Azure so that a script runs that checks the CPU Usage and if the average for two hours is less than 10% it shuts down the VM?
Has anyone got an example script?
I do not have example code, but would start with Azure Monitor. Using Azure Monitor you can create an alerts with specific criteria such as CPU usage and a time slice.
Create, view, and manage alerts using Azure Monitor
On alert you can engage an Azure Automation Web-hook to perform the remediation action.
Webhook actions for alert rules
Azure alert rules are probably the way to go here. Here's an end-to-end solution with that.
A simpler way to do it is using a tool like VMPower which isn't free but is inexpensive and works best when you need to do this across multiple VMs with different auto-stop configurations.

Compare: Azure Functions vs Azure Batch

Can we use Azure Functions along with Azure Batch? Please Advise.
I am working on a POC to decide which one to use for our background processes.
I too was in similar dilemma till I tried both of them for my use case.
The major difference between the two is that Azure Function has a hard timeout limit of I guess 10 minutes which you can not exceed. What I mean is that if your script/execution runs beyond 10 minutes then Azure function will kill it automatically.
Whereas Azure batch is essentially a configuration of pools or VMs in which you can run long running jobs where you are not bothered about the time of its execution. Essentially they are old VMs (low costs too). Difference between batch and Azure VMs is that Azure VMs have high speed VMs but in batch you can configure the periodic jobs where in Azure VMs you need to code in such a way that it executed like a periodic job
And yes it is possible to use Functions with Azure batch. You can configure your script as HTTP trigger in Function which you can call (get/post) through Azure Batch VMs.
Hope it helps.
May be we should expand this topic to Azure services for Batch processing in general. I did come across an article from Microsoft that goes through these options in general (which includes Web Jobs, and Kubernetes options).
But, frankly, even after reading the article; the confusion remains. For example, Azure Batches can be scheduled; but not sure if they can be triggered based on other Azure services like how Azure web jobs handles it. I get a feeling that Azure Batch is pitched where you need high + parallel computing at low costs. Because, none of the other options directly allow you to low-priority and low-cost compute instances. Correct me please!
#AzureBatch #AzureWebJobs #AzureAKS #AzureFunctions

Difference between Azure Worker Role & Azure Automation?

Are these 2 totally different things or are they roughly same/similar in what they can accomplish?
Azure Worker Role is your own set of virtual machine in a "application farm". You can run any code on them in a distributed fashion. Typically, you write business code to run on these servers (ie: order processors, customer emailers, cloud-to-premise synchronizers, etc)
Azure Automation is meant more for automating administrative tasks such as:
Reboot your servers once per day.
Deploy bits to staging environment.
Run connectivity tests against a particular resource, etc.
Azure Automation is written in Powershell which is great for accomplishing small administrative tasks. I would not want to write a complex order processing system in Powershell though :O
Furthermore, with Worker Roles you kind-of have decent control over the VMs that run your code. Can install third-party components on them, access local storage, basically do whatever a regular C#/VB.NET program can do. Automation is a service to automate admin tasks.
HTH

How can I set up a CRON job using Windows Azure?

Is there a way to use the windows scheduled task to kick off a url or a exe on a schedule?
Can I write a program as an exe then create a Azure VM then RDP into the Azure VM and hook it up to windows task scheduler?
Azure does have a scheduler now.
It allows invoking a Web Service over HTTP/s and post a message to a Windows Azure Storage Queue. It's very new but it can be free if you do not need the scheduler to be executed often. Otherwise it's a small monthly fee which come with scheduled task that can be up to every minute.
Things got much easier lately, please see this link https://azure.microsoft.com/en-us/services/scheduler/ to create a scheduled job in the new Azure Scheduler. There is a basic Free tier as well as some paid options but I think this is exactly what many of us were looking for. It is an excellent solution for triggering URLs with GET,POST,PUT,DELETE requests.
Just follow the simple instructions. Starting by selecting "Scheduler" from the Azure dashboard app menu:
Today the scheduler has been Azure Logic Apps:
https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-overview
If you are looking for something like a cron job (which is a job, that is being run at specific time again and again), then check out Azure Functions:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview
Google Azure Storage Queues. They allow you to schedule jobs that will run at a later date. You can even specify when the job should run.

Resources