How to monitor Azure IaaS VM availability. how to get alerted in case if the VM goes down or gets restarted.
Existing Azure monitoring / Alert and diagnostics providing alerts on perf counters like CPU, memory and networking. Is there any KPI that we can consider as for to alert in case VM goes down.
We don't want to invest on SCOM and find an alternative for this.
You can use Azure Monitoring for that and also create alerts and use them based on performance counters (CPU / memory, etc)
Azure Monitoring
https://azure.microsoft.com/en-us/documentation/articles/monitoring-overview/
Receive alert notifications
https://azure.microsoft.com/en-us/documentation/articles/insights-receive-alert-notifications/
You can use it directly through the Azure Portal, or connect using c# for example. All the information you need is on the link above.
I had good results with the "Network In" metric.
Set an alert for "Network In" with these settings: number "Less than", time aggregation "Total", threshold "15000 bytes" (see what number works best for you) for a period of "Over the last 1 minute" with a frequency of "Every 1 minute".
How many VMs do you have running in your subscription? If you're running websites or web services then you could setup a site-to-site VPN tunnel and utilize PowerShell scripts to test availability. We use Task scheduler to call PowerShell scripts that perform HTTP GET against websites on specific machines to ensure that the machine is up.
You could also use Get-AzureVM to test for status of the VM.
Related
I've "Visual Studio Enterprise" azure subscription. I initially got few credits. I think it was $200 for free. Earlier it used to show static remaining credit i.e. if I built two VMs and it cost $50 it would show $150. But since few days may be just past day remaining credit is continuously reducing.
The activities I have done so far. Earlier I was unable to connect to VM as outgoing connection was not allowed from my organisation. Since I have got permission I'm able to connect. After that I installed Active Directory Services on one of the VM.
I don't think till this step my credit amount got reduced except for the VMs I built.
I was trying to start and stop the VM using powershell but I wasn't able to do so. So I installed powershell azure modules. using Connect-AzAccount to connect and then used Start-AzVM and Stop-AzVm to start and stop the VMs. Just to clarify I keep the VMs in shut down mode so I don't keep getting billed.
Still the amount is being deducted. I ran Disconnect-AzAccount on suspicion that it might be causing the issue but still it hasn't fixed the issue.
Can any one help here?
There are mainly two ways to stop VM:
Stop the Azure VM locally: When you connect to the Azure VM with remote desktop, go to the Power options within Windows and select Shutdown, this will essentially “turn off” the VM and stop it from running. However, even though the VM won’t be running you WILL still be paying for the Virtual machine hardware allocation. Doing this will cause the Azure Portal to report the status of the VM to be “Stopped”.
Another way is to click Stop in the virtual machine page on the portal(or use Azure PowerShell or Azure CLI). Instead of just shutting down the Operating System, Azure will also deallocate the hardware (CPU and Memory) allocation. Doing this will cause the Azure Portal to report the status of the VM to be “Stopped (Deallocated)”.
Overall, both methods will reduce cost but not none of cost. You do still pay for the Azure Storage account usage, which is used for storig the VM’s .vhd disk image file. As a result, you will still incur some cost for the storage, but at least you will save on the VM resources.
Ref: Properly Shutdown Azure VM to Save Money
You need to identify what resource are been billed when VM is stopped or Stopped De-allocated.
Check the Cost analysis under Cost Management to identify the resource. Note that when VM is stopped you still pay for storage and other resources depending in your setup.
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.
Recently, i have been introduced to Azure and i have an application that is using high CPU (almost 80%) during morning hours between 9 am to 1 pm. After that the CPU utilization is reduced to a minimal of 10% the whole day. So in order to reduce my cost i was thinking to implement vertical auto-scaling in my application. When i read more on this i could find automation account and RunBook as the only way but my need is that is there any other way to implement Vertical auto-scaling in Azure IaaS VM apart from automation account?
If Yes, please share the approach.
Yes you can use Azure PowerShell and/or the Azure CLI to execute scaling commands on a VM. Here are some PowerShell examples: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/resize-vm?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Ftoc.json
You would then just have to schedule the script to run either locally or in an Azure service like Functions, Container Instances or etc.
If you wanted to scale vertically a single VM based on a performance metric (CPU, memory, etc.) you can use the classic metric alerts system to do that. When those alerts fire based on thresholds you set you can invoke a webhook OR Logic App to trigger execution of a script or ARM Template.
When Azure shuts down a VM for planned maintenance, what messages do running services see, if any?
For example, do they get a ServiceBase.OnShutdown() message and, if so, how long does the service / server get to complete shutdown processing?
Does MS give any extra leeway to its own apps? E.g. if a VM is running SQL Server, will Azure wait for SQL Server to stop cleanly before shutting down the VM?
[I can't find this in the documentation and, unfortunately, I don't have the access or the programming skills to try it out for myself.]
what messages do running services see, if any?
Based on my knowledge, for now, Azure does not support this. Please refer to this feedback.
Typically maintenance is performed at weekends for VMs not in an availability set to minimize impact on services. Normally notification is given 7 days in advance with the minimum being 3 business days. A start time for the maintenance is given with the expected duration. More information please refer to this link.
According to your description, I suggest you could provision another IaaS VM with your SQL server and put in the same Availability set. By doing this, Azure will ensure that both your VMs do not go down simultaneously.
I recently implemented SSRS on a Azure VM and was very surprised when I realized I would be billed for 100% of the hours in a month if my VM was running. This runs around $200 and is in no way economical for our small reporting service we use for about 5 days month. What are my options for reducing VM hours?
I have already established I can shutdown and deallocated the machine when we are not using it. Ideally though the service would go into some kind of sleep mode and reallocate when the service is pinged.
You pretty much figured it out: When a VM is running, you're billed for it. This is how it's always been in Azure: Whether utilizing 0% or 100% of the VM, you're billed for the running VM. Think of it as paying for reserved resources. Just like an apartment, where you pay for the rent even if you're using it 0% (e.g. not home).
You can choose to stop the VM at any time, and billing stops, until you start the VM again. This is easily done via PowerShell / CLI, so you can automate it with your own tooling.
Note that VM billing is actually per minute, so if you shut down a VM after 30 minutes, you're not billed for an entire hour.
Only you can decide the proper way to manage your VM's uptime, based on your app's usage. There's no single right answer to that. And there's no mechanism for the VM to sleep if it detects inactivity. That's going to be an application-dependent thing (deciding when to shut down).
You have a couple of options to correct address this:
You could use automation, where you run a Powershell script to turn you VM off during off-peak time. Check this out:http://azure.microsoft.com/blog/2014/08/20/azure-automation-capabilities-in-depth-the-azure-automation-powershell-cmdlets/
You can setup alerts now in your account portal (yeah, I just said that!) Check it out here: http://azure.microsoft.com/en-us/documentation/articles/azure-billing-set-up-alerts/
I would look at both. You can shut-down a VM from PowerShell (MS just demonstrated that to me in a workshop this week), so I would use this approach if you know that SSRS is only going to run for a specified window.
You can also check Azure automation option if you have a definite schedule for the VM to be up and down. Azure automation gives you a way to create a runbook to manage the up time of the VM and also options to do the scheduling. Check this blog for more information https://blogs.endjin.com/2015/01/using-azure-automation-to-run-vms-during-office-hours-only/