Manage your Azure resources with PowerShell

PowerShell is a great tool for automating simple tasks and also works with Windows Azure.
I personally use it to start and stop a Virtual Machine which I’m not using on a regular basis to save some money. By using these scripts I don’t have to login to the portal anymore to start and stop the VM. There are a lot of other usages for PowerShell and Azure, but I will get to that later.

Let’s start with setting up PowerShell and Azure (you only have to do this once). First you need to install Windows Azure PowerShell, by downloading it here.

The Web Platform Installer installs all dependencies for the Windows Azure PowerShell cmdlets. After installing you need to setup your Azure subscription so that it can be used to manage your services. You can do this by opening a PowerShell command prompt and type:
Get-AzurePublishSettingsFile.

Get-AzurePublishSettingsFile
After hitting “enter” a browser window opens and (after you logged in) will prompt you to download the .publishsettings file.

Azure Portal download publishsettings file powershell

Once saved, I used the Import-AzurePublishSettingsFile to imports the .publishsettings file for use by PowerShell. This file includes a management certificate that contains the security credentials.

Import-PublishSettingsFile

Now you’re all set to manage your Azure resources from within PowerShell.

Here are some commands to get you started:
To view your Virtual Machines:
Get-AzureVM

To start a VM:
Start-AzureVM -Name “VMName” -ServiceName “ServiceName”

To stop a VM (The -Force will deallocate your VM, this status will not incur any compute costs.):
Stop-AzureVM -Name “VMName” -ServiceName “ServiceName” -Force

View a list of your Azure Websites:
Get-AzureWebsite

Details of an Azure Website
Get-AzureWebsite -Name <websitename>

Scale your Azure Website to 2 nodes:
Set-AzureWebsite -Name <websitename> -NumberOfWorkers 2

You can find a list of all the commands over here: http://msdn.microsoft.com/en-us/library/jj152841.aspx.

For more inspiration on what you can do with PowerShell and Azure I recommend to look at the Script Center:
http://www.windowsazure.com/en-us/documentation/scripts/

Remotely debug your Azure Websites with Visual Studio 2013

Today the new version of Visual Studio (version 2013) will be officially launched. With this new version it becomes very easy to remotely debug your Windows Azure Websites.

In order to remotely debug your site you will need to download and install the following:

  • Visual Studio 2013 (I used the release candidate of the Premium edition).
  • And the Azure SDK 2.2

 

Here is how you do it
First you need to deploy your site in debug build configuration, otherwise you’re breakpoints won’t be hit.

Next you need to add your Azure subscription to Visual Studio so you can manage your subscription from within Visual Studio 2013.

To add you need to right click on “Windows Azure” in the Server Explorer (Ctrl+W,L) and select “Import Subscriptions…”

Select Import Subcriptions... to start adding your Azure subscription to Visual Studio 2013

Import Subscriptions…

A popup will appear.

Download and Import your subscription into VS2013

Download and Import your subscription into VS2013

If you haven’t downloaded your subscription file before, you can download it via the “Download subscription file” (1).

After downloading you can select that file via Browse (2), and click on Import (3).

When the import was successful, you can manage all your Azure services from within Visual Studio.

Now you can see your Web Sites under the Windows Azure node in Server Explorer. Right click on the site that you would like to debug and select Attach Debugger. When this is invoked the remote debugging agent will be started on your web site.

Attach the remote debugger to your Azure Website in Visual Studio 2013

Attach the remote debugger to your Azure Website in Visual Studio 2013

When the debugger is attached ALL the breakpoints from every request to the site will be hit. So don’t use this on a site with a lot of users :-)

To filter the requests from only your IP address you can add a filter to your breakpoint by right clicking on your breakpoint and select “Condition…”.

Add breakpoint filter

Add breakpoint filter

The following popup will appear.

Filter on IP Address

Filter on IP Address

As you can see in my code above, I assigned the Request.UserHostAddressip to a local variable ip.
string ip = Request.UserHostAddress;
So now I can add the condition to check if ip is my IP address. The breakpoint will only be hit if this condition is true.

It would be a lot easier to set the condition to: Request.UserHostAddress == "1.1.1.1", but that didn’t work… Probably because the debugger doesn’t have the Request object in scope. Do you have a better idea?

Innoveer jij mee – Windows Azure Mobile services

Donderdag 17 oktober is er, op ons hoofdkantoor in Nieuwegein, een Ordina innoveer jij mee sessie die voor iedereen toegankelijk is over Windows Azure Mobile services. Kom jij ook?

Windows Azure Mobile services
Mobiele apps zijn niet meer weg te denken. Maar voor de goede werking van die apps is vaak een backend nodig om gegevens op te slaan, push notificaties te kunnen versturen en gebruikers te kunnen authentiseren. Windows Azure Mobile Services maakt het eenvoudiger om snel mobiele apps te maken met Windows Azure als backend. Dit platform beperkt zich niet alleen tot Windows Phone 8 en Windows 8, maar ook iOS en Android worden ondersteund.

Tijdens deze sessie zal met demo’s getoond worden hoe je mobiele app eenvoudig gebruik kan maken van Windows Azure Mobile Services. Onder andere het opslaan van je gegevens in een Windows Azure SQL database en het toevoegen van Push notificaties aan je applicatie komen aan bod. Al deze taken worden door het gebruik van de Windows Azure Mobile services een stuk eenvoudiger gemaakt.

Meld je aan via de site van Ordina

Working with the auto-scaling feature for Windows Azure Websites

On the Build conference Microsoft announced a new feature called auto-scaling. This enables you to setup automatic scale rules based on the activity of your instances – allowing you to automatically scale down (and save money) when they are below a CPU threshold you define, and automatically scale up quickly when traffic increases.

The auto-scaling feature is also available for Cloud Services and Virtual Machines, but in this post I’m only going to talk about Azure Web Sites.

To set up a new rule you log in to the portal. Go to the web site you want to automatically scale and click on the tab “Scale”. The feature is only available in the STANDARD mode.
In the picture below I configured my test website (called “autoscale”) to use a minimum of 1 instance and a maximum of 4 instances.
The Target CPU slides says it will scale up when the average CPU utilization comes above 75 percent and will scale down an instance if the utilization drops below 30 percent.

AutoscaleWebsite

In the gray box you can read “Autoscale has reduced your costs by up to 50%“. This is Microsofts way of saying that you’re using 2 instances (50% of my maximum of 4).

In the graph you can see I have been testing the service by doing some load test on the site. In general the autoscaling feature worked great. Only thing I noticed is that it sometimes takes up to 30 minutes before the site scaled up.

Great new Azure announcements @Teched 2013 North America

Last week was Teched 2013 North America, and there were a lot of exciting new announcements made by Microsoft. If you have 3 hours to spare… watch the complete keynote here.

Here’s a summary of all the new thinks I found on Windows Azure.

Stopped VM’s will not be charged anymore
This is a great feature for my development and test environment where I always had to remove the VM to stop the charging.
As a bonus Microsoft changed from charging by the hour to charging by the minute!

MSDN Subscription benefits
As a MSDN Subscriber I’m excited about the new improvements. I can now use more resources, have the legal right to use the dev/test server licenses provided by my MSDN subscription and have a nice overview of my credit usage in the portal. (Read the detailed blog post by Scott Guthrie).

SSL Support with Azure Web Sites
If you put your site in Reserved mode you have the ability to upload a SSL certificate for your custom web-site domains. Don’t forget to select the SSL Binding after you upload your certificate… It took me an extra coffee break before I figured out why it didn’t work right away :-)

BizTalk Services
Microsoft announced a new service called BizTalk Services. It is a managed services which provide integration capabilities for the Windows Azure Platform to extend on-premises applications to the cloud. To try the new service you have to sign up via the Preview Features page in the portal.

Watch this episode of Cloud Cover show for more details.

Windows Azure Pack
Windows Azure Pack is the new name (and next version) of “Windows Azure Services for Windows Server” expected later this year.
The Pack will be an installable feature for Windows Server 2012 R2 and will bring some of the features that are currently Azure-only to the server platform.

Watch the video of Scott Guthrie wearing a BLUE shirt(!) talking about the Windows Azure Pack.

Windows Azure Update

Today Microsoft announced a bunch of new updates on Windows Azure. Here’s a sum up of the updates announced today:

Windows Azure Active Directory Reaches General Availability
Windows Azure Active Directory (AD) has reached general availability and is now ready for production use!
Vittorio Bertocci also announced some new features: read his blog.

Backup and Recovery Services
A new service announced today is the ability to enable backup and recovery protection with Windows Server. You can manage your cloud backups from the familiar backup tools in Windows Server and System Center Data Protection Manager to provide a consistent experience configuring, monitoring and recovering backups across local disk and cloud storage. More info can be found here.

Monitoring and Diagnostics Improvements on Azure Web sites
Azure Web sites is still in preview, but got some new monitoring and diagnostic capabilities. This includes the ability to easily turn on/off tracing and store trace + log information in log files that can be easily retrieved via FTP or streamed to developer machines.
Read Scott Hanselman’s Blog for all the details.

TechDays Netherlands 2013: Migrating to the cloud

techdays2013

Yesterday I presented at TechDays Netherlands in the World Forum in The Hague. My session subject was “Migreer je applicatie naar de cloud”. Yes, it was in Dutch!

My session was about migrating applications to the cloud. I talked about the advantages of cloud, how to prepare and migrate and finished with some tips and tricks.

The slides can be found for download here (PDF)..
он лайн заявка на кредит
professional assignment writing service

Concurrent connections to MySQL in Azure

For a customer we needed to migrate a high traffic WordPress site to Azure. Using Azure Websites it was a breeze to migrate the site. We used the W3 Total Cache plugin for caching and serving static content from Blob storage. This seemed to be a simple migration…

But after some performance test with 2 reserved instances we got a lot of “Error establishing a database connection” messages. To find the limitations of the MySQL connections in collaboration with Azure Websites I did a little research.

For the research, I made use of:
- 2 different MySQL database variants from ClearDB. A free version (Mercury, max 20MB of data and max 4 connections) and a paid version (Venus $10 p/m, max 1GB of data and up to 15 connections).

- A standard WordPress site installed via the Azure portal. I didn’t modify the source code, apart from changing the database connection in wp-config.php. For database filling I only added 2 blog post with ~1000 words.

- A self-made Console application to perform a load test on the website. (See Attachment for source code)

The research
Web site mode “Free” and free (Mercury) MySQL database.
I have tested up to 25 concurrent users (seems sufficient for free hosting). No database error occurred.

Web site mode “Shared” and free (Mercury) MySQL database.
Up to 4 concurrent users no errors. With more than 4 concurrent users I got the “Error Establishing a database connection” error messages.

Web site mode “Shared” and paid (Venus) MySQL database.
Up to 5 concurrent users I didn’t get any error messages, with more than 5 concurrent users occasionally an “internal server error” occurred. Because I’m interested in much higher load I didn’t investigate these errors.

Web site mode “Reserved” and paid (Venus) MySQL database.
1 small instance: up to 100 concurrent users tested, no error message.
1 medium instance: up to 100 concurrent users tested, no error message.
1 large instance: up to 300 concurrent users tested, no database error (response time per page rose to 4 seconds, so more users means scaling up).

2 small instances: up to 15 concurrent users no error messages, but with 16 concurrent users (and more) the famous “Error Establishing a database connection” error message occurred.

Conclusion
“Free” sites can only create 4 connections to the database, a higher load will be throttled by your webserver and no database errors will occur.

“Shared” websites can use more than 4 connections to the database and, with more than 4 concurrent users, your visitors will get error messages when you’re using a free database. When you’re using the paid Venus database, you will not get the database error messages. (I cannot explain the server error messages at a higher load).
A single “Reserved” instance can use a maximum of 15 connections to the database. A Venus database has a limit of 15 connections, so this is just right. I didn’t get any “Error Establishing a database connection” error messages. At high load, the response time became longer, but no error messages occurred.

With 2 “Reserved” instances you can get 2 x 15 connections to the database, so with more than 15 concurrent users, database errors will occur with a Venus database.
My expectation is that a Saturn database (price $ 50 per month, max 5GB, 30 connections) will keep you away from connection errors here.

If you have a high traffic website and need more than 2 “Reserved” instances the standard ClearDB offerings will not be sufficient. With 3 instances you will get 45 connections and the biggest offering (Jupiter) has a maximum of 40 connections.

For our customer we asked ClearDB to create a dedicated MySQL cluster ($399.99 per month). This baby can handle a lot of concurrent connections and I haven’t be able to produce a “Error Establishing a database connection” message any more (even with 10 instances)