How to check what is causing CPU bottleneck on Azure - azure

I can't find what is causing CPU increase to 100% daily at some periodical time. Is there any way like if you have VM, task manager in Azure dashboard?
I have telemetries:

You can remote debug your Azure app with Visual Studio :
When you enable remote debugging on an Azure virtual machine, Azure installs the remote debugging extension on the virtual machine. Then, you can attach to processes on the virtual machine and debug as you normally would.
https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-debug-cloud-services-virtual-machines/#debugging-azure-virtual-machines
Also to try to understand what happened in the past: if you have activated Azure Diagnostics, you get the output logs in a Azure Storage that you configured for diagnostics. You can have a look at there to try to find what caused the problem.
You can integrate app logs to azure logs to get more accurate or specific info.
https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-dotnet-diagnostics/
You can also use 3rd party logs like log4net, ... (see appropriate extension or nuget packages).

Related

How to enable logging in new Azure VMs, automatically?

I have created a custom OS images on Azure containing my app, omsagent, and a configuration file to track my application logs. I verified that the custom logs were available on Log Analytics Workspace for that VM.
When I create a new VM with this custom OS, using Python SDK, I don't receive logs in the workspace. I verified that omsagent is working. It is sending heartbeats that are visible on the Log Analytics Workspace > Insights > Agents.
I found out that the new is was not Connected to the workspace.
So my question is how do I automatically connect a VM to Log Analytics Workspace at creation time?
I would advise against baking the Log Analytics Agent (OMS Agent) into the image directly - Azure doesn't recommend this kind of setup. Instead, you should be using an Azure Policy that they provide exactly for this scenario.
We have dozens of VMs and Scale Sets we need to manage with Log Analytics Agent installed on each of them when we build the custom images. In the beginning everything was working fine but a couple of months later those images stopped working.
After spending some time investigating with the Azure team we found out that the agent's certificate wasn't being renewed and it wouldn't connect to the Workspace automatically. Even worse was that because of this, it was failing all our images builds.
We were told that this is not the right practice and we should look at Azure Policies. They are rather easy to setup - just assign once and forget about them. It's also good for compliance and will let you know if there's any machine that's non-compliant.
Check this link for more info about Azure Monitor policies.
And this link will open your Azure Portal directly into the policies page for Windows VMs.
Here's a preview of the policies available:

How to view errors being generated by Azure Compute Emulator

I have a WCF service solution which contains the WCF service and a Azure Cloud Service project.
When running the cloud service project in the Azure Compute Emulator (version 2.5 on my PC), all I see in the output for each role is
[fabric] Role state Busy
[fabric] Role state Aborted
I've tweaked the logging level in Compute Emulator to log Warning, or Error and even tried Critical, but no more detailed messages are displayed. I have been Googling to see if there are any event log entries, or log files on disk, that I can view to find out why the cloud service is not working, but to no avail.
What can I do to find out more about what is causing the Cloud Service role to abort and and retry?
Diagnostics logs are not collected in the Azure compute emulator – For projects that target the Azure SDK version 2.5, the Azure compute emulator no longer supports the collection of diagnostics logs, including performance counters, infrastructure logs, IIS logs, and event logs. In addition, logs are no longer stored in Azure storage or development storage. You can continue to view application logs in the Visual Studio Output window or the compute emulator. This only affects projects that target Azure SDK version 2.5; projects that continue to target Azure SDK 2.4 are not affected.
Source: http://msdn.microsoft.com/en-us/library/azure/dn873976.aspx
In my case, it turned out to be a startup task defined in ServiceDefinition.csdef that was the problem. After I removed the <Task> my service ran fine in Compute Emulator.

How to configure Anti Malware for cloud Services

Is there a way to enable Anti-malware monitoring of cloud service. With the latest release for enabling cloud service, should we still need to have power shell has start up for cloud Services and Power-shell will invoke XML template of anti malware.
I could not be proper documentation of how to enable from Cloud Services solution perspective
Here are the Some of the questions:
Should i still need to have Power shell has startup and configure it
for CSDEF file
Where should i place xml template in cloud project, in the power shell, we need to give location of xml file, should xml file and power shell script should be # same level i.e in the same directory
If we enable Monitoring of Anti malware services for cloud services, we need to give storage account, is there a way where storage account pickup dynamically based on envrionment we are deploying. End of the day,I'm looking for automated way of setting Monitoring in Production and UAT envrionments
Use the PowerShell cmdlet, Set-AzureServiceAntimalwareExtension to enable antimalware in your cloud service. Here's some more info:
Set-AzureServiceAntimalwareExtension
For installing any software in a cloud service, the approach I've found to be best is to implement the OnStart() method in the WebRole.cs class of a project that you've deployed. (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.serviceruntime.roleentrypoint.onstart.aspx)
You can do something like:
Download the software you need, or reference a file you've bundled with the code.
Install it.
Configure it.
Run it.
For the big picture - monitoring environments - I wouldn't spend too much time on anti-virus/malware software. No one is installing that if they can't get access to your machine.
Things you can do to lock down your machine/monitor it:
Make sure all your endpoints are locked down. Only expose ports that need to be used, for example, port 80 for HTTP.
Use SSL for HTTP.
Install something like Bosun (http://bosun.org/) or Opserver (https://github.com/opserver/Opserver) to monitor CPU, RAM, network connections etc.
(Note: Tried installing Bosun on a Windows Cloud Service earlier this week and not all the metrics seem to be reporting.)

Is it possible to suspend and resume a windows Azure server?

I have a program that I run only 1-2 hours a day. Is there a way to suspend the Azure server so I don't pay for it, then resume it later? How fast is it to suspend and then resume?
To clarify here, Azure no longer charges for stopped VMs. The billing change was announced in 2013 on Scott Guthrie's blog: No Charge for Stopped VMs.
This means you can use the portal or APIs to stop a VM without deallocating the resource - and avoid charges at the same time.
Not sure if you are asking for Window Azure Cloud Services or for Windows Azure Virtual Machines but you sure can stop/start these Azure Virtual Machines directly on Windows Portal or using Powershell or REST based Service Management API. The Windows Azure Portal does not provide a way to schedule stop/restart so you will have to manually do it by yourself or use some 3rd party service i.e. AzureWatch etc to do it.
Note: Even if you shutdown the Virtual Machine or Cloud Service, you will still pay for if you want to do it for cost saving, then you would need to delete the service or VM. Reboot/Restart does not take long as VM is already configured and ready to run so it is just the time to turn on a pre-configured VM.
If you want to use REST API in your own application to stop/start here is some help:
Virtual Machines: http://msdn.microsoft.com/en-us/library/windowsazure/jj157206.aspx
Cloud Service: http://msdn.microsoft.com/en-us/library/windowsazure/gg441298.aspx
If you want to use Powershell to stop/Start Azure VM look for "Start-AzureVM" and "Stop-AzureVM" cmdlet below:
http://msdn.microsoft.com/en-us/library/windowsazure/jj152841.aspx
To save money, I did Remote Desktop to my Azure Windows VM, and clicked shutdown.
Then, at my Azure dashboard (https://manage.windowsazure.com) > VIRTUAL MACHINES > STATUS it changed from Running to Stopped.
But then I read this doesn't stop the billing.
So I went to Microsoft Azure > Virtual machines (classic) >
and saw the status was Stopped. But this doesn't mean billing stopped.
I clicked the "stop" command, and it changed to Stopped (deallocated) which means no (or near 0) billing.
The screenshot says it all... so only a "deallocated" VM won't be billed!
One more thing to add. As opposed to a deleted VM, a deallocated VM still has virtual disks attached to it which consume storage space and therefor creates costs.
If you mean the "suspended" state you can achieve with your computer I don't think is available today on Azure.
Google Cloud for example has just released that feature on beta https://cloud.google.com/compute/docs/instances/suspending-an-instance

Azure: Deploying a Ruby on Rails app in the Cloud

I've just completed an automation script that:
downloads a project build to local storage (worker role)
installs ruby, apache, and other dependencies
configures apache and the RoR application to serve requests via port 81
This is all working locally. I'm working with visual studio; running the application successfully pulls the local machine from "blank slate" to "serving requests".
I'm now trying to push this up to Azure - no longer using the local machine, but an actual worker role.
I've packaged the project and uploaded it to a production environment via my Azure subscription portal, but navigating to the site URL doesn't give me anything (site not found).
I'm a bit new to Azure. What steps do I need to take to ensure that this application will work up in the cloud? I feel like I've forgotten to configure something, like the endpoint port (81). Any advice or recommended reading would be super helpful; thank you so much for your time!
If you need some real assistance to troubleshoot the problem, tt would be best to see the following 3 things:
Your automation script (Startup Task)
Your worker role OnStart() function
Your ServiceDefinition and ServieConfiguration
Are you using ProgramEntryPoint to luanch your RoR app or you are doing all of this in Startup task? Based on above info, it is easy to understand the application architecture and some suggestions can be made.
However, the best way to troubleshoot this problem is to enabled RDP access to your Azure Worker Role VM and then Log into your Azure VM to understand what is going on. RDP access to Azure VM will validate that your install script ran correctly and all the modules were started.
As your are new to Windows Azure there could be several things could be missing and if you provide more info you will get accurate help instead of some guess work.

Resources