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.
Related
In order to save expenses in Azure DevOps, I'm trying to scale the resources, which can scale depending on the requirement. Team leads will update the resource requirements in SharePoint, and the runbook needs to be executed with SharePoint datat. Team leads will update the resource requirements in SharePoint, and the runbook needs to be executed with SharePoint data. If such resources are not required on weekends but must be operational on weekdays, they should be stopped or reduced in size. I need to use automation to do it for all of the VMs and App Services at a subscription level every Friday. If there is a method to automate this procedure using PowerShell.
I'm glad to receive input. Thanks in advance.
I'm looking for feedback on Start/Stop VMs and Scaling Azure App Services. On weekends, the same may be said for other relevant resources. How can we accomplish this with Azure PowerShell?
The best way to do is by using 'Azure Automation Runbook' scheduled to run every specified day or date by time. To target the VM's, Azure Tags will be much helpful.
Your script must check:
A VM has a specific Tags (e.g., StopVM:Friday 11:00PM)
Maintenance Enabled in your monitoring solution
VM is stopped already or not.
Backup required?
Confirm the VM is Deallocated (not stopped)
Auto-Shutdown option is also available to do this activity.
Because sometime all you need is a quick and dirty way to save money :
And if you wan't to build something there's an API to shutdown and start VMs
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.
Currently, we are hosting five websites on a Linux VM. The websites reside in their separate directories and are hosted by Nginx. The SSL is terminated at Azure Application gateway which sends the traffic to the VM. If a file is updated in a remote repository, the local copy is updated by a cron task which is a simple Bash script running git pull and few additional lines. Not all five websites need to be updated at the same time.
We created the image of the VM and provisioned a VMSS set up.
What could be the easiest or standard way of deploying the codes to the VMSS? The codes also need some manual changes each time due to client's requirements.
Have a look into Azure Durable Functions as an active scripted deployment manager.
You can configure your Durable Function to be triggered via a cron schedule, then it can orchestrate a series of tasks, monitoring for responses from the deployment targets for acceptable response before continuing each step or even waiting for user input to proceed.
By authoring your complex workflow using either of C#/JavaScript/Python/PowerShell you are only limited by your own ability to transform your manual process into a scripted one.
Azure Functions is just one option of many, it really comes down to the complexity of your workflow and the individual tasks. Octopus Deploy is a common product used to automate Azure application deployments and may have templates that match your current process, I go straight to Durable Functions when I find it too hard to configure complex steps that involve waiting for specific responses from targets before proceeding to the next step, and I want to use C# to evaluate those responses or perhaps reuse some of my application logic as part of the workflow.
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.
This is essentially a question about saving money - we have build machines in azure - but they are only active for about 8 hours a day. Is there any easy way to create a schedule, so they are taken off line for the rest of the time, so we only pay for 1/3 the amount of compute time?
Darren
Yes , its possible. There are two options available
Via Powershell
http://gallery.technet.microsoft.com/scriptcenter/Start-Windows-Azure-b6c179b6
Using Azure VM As scheduler.
http://clemmblog.azurewebsites.net/start-stop-windows-azure-vms-according-time-schedule/
The thing that you can do is using a Powershell script to start/stop the VMs at certain times.
You can find a draft at the Azure Management Portal, under Automation ==> Runbooks.
There you can also find runbooks to scale your machines over the night, to cut costs ever more.
I hope this helps :)