Continuous Deployment in Windows Azure Web Sites

Automation of tasks is one thing that I am an advocate of in my development projects. Getting functionality that is repeatable with a low risk of human error for a one time cost is a sound business decision and as a developer, keeps your hands on rolling more code for a greater percentage of your work day. It’s a Win-Win scenario.

The Windows Azure Web Sites team along side the Kudu team have added Continuous Deployment functionality in Windows Azure Web Sites with support for three familiar social source code repositories: CodePlex, GitHub and BitBucket. The team has also added support for Contiguous Integration using Team Foundation Service [a new Cloud Based offering of Team Foundation Server].

Windows Azure Web Sites now allows Continuous Deployment from Private Repositories from both GitHub and BitBucket.

In this post:

  1. Create a Windows Azure Web Site
    1. Enable Git Deployment
  2. Associate a Source Code Repository
    1. Associate a GitHub Repository to Windows Azure Web Sites
    2. Associate a BitBucket Repository to Windows Azure Web Sites

Create a Windows Azure Web Site

To avoid reinventing the wheel, you can follow instructions outlined on the Windows Azure Develop Center on how to Create a Windows Azure Web Site and Enable Git Deployment.

NOTE: If you do not need a MySQL database, or have decided to go with another database option, choose Quick Create from the Web Site menu instead of Create with Database.

Associate a Source Code Repository

In order to facilitate the Continuous Deployment it’s necessary to have a centralized location to pull the website code from, in this particular blog entry we’re going to use GitHub and BitBucket.

Initializing a Git Repository will redirect the Management Portal to the DEPLOYMENTS tab.

Now that Git has been enabled use the collapsible menus to select how you would like to deploy code to the new Windows Azure Web Site.

Associate a GitHub Repository to Windows Azure Web Sites

GitHub-Deployment-Accordion

Expand the item labeled Deploy from my GitHub repository.

GitHub-Deployment-Steps

Click on Authorize Windows Azure. This will open a window to federate with GitHub, you will need to approve the ability for Windows Azure to access your GitHub account.

GitHub-Authentication

Once access has been granted, the browser will redirected back to the Management Portal to a screen to select either a Public or Private repository.

GitHub-Select-Repository

After selecting the repository to be published, click on the check mark to start the deployment process.

If your repository is empty, push to GitHub to trigger deployment to Windows Azure.

GitHub-First-Deployment

Each subsequent push to GitHub will trigger a service hook and begin a deployment of the latest bits to the Web Site. Now that the deployment has been pulled into the Web Site, clicking on Browse in the Taskbar Drawer will launch the web application.

GitHub-Published-Custom-WordPress-Site

Associate a BitBucket Repository to Windows Azure Web Sites

BitBucket-Deployment-Accordion

Just like associating a GitHub account to a Windows Azure Web Site, expand the Deploy from my BitBucket repository. Authorize Windows Azure to access a BitBucket account by federating authentication through BitBucket.

BitBucket-Deployment-Steps

After clicking on Authorize Windows Azure, a prompt to authenticate with BitBucket.

BitBucket-Authentication

After signing into BitBucket a prompt to select the Public or Private repository to deploy to Windows Azure Web Sites.

BitBucket-Select-Repository

Unlike GitHub, BitBucket will require you push a change to the repository before the Service Hook will deploy code to the Windows Azure Web Site.

image

Once a push has been made to the private BitBucket repository, the deployment will be pushed to the Web Site.

image

In the taskbar drawer at the bottom of the browser viewport, click the Browse Button.

image

A new window will open and the site will display the web files which were pulled into the Web Site.

Conclusion

Continuous Deployment is a great way to introduce new features or functionality to your customers in an automated fashion. With the new support for Private Repositories, Windows Azure Web Sites can help delivery stunning web sites which utilize either open source projects from public repositories, or provide clients with a customized solution from a private repository.

Stay Cloud my Friends…

PHP 5.4 Now Native in Windows Azure Web Sites

A while back I wrote a blog post on Enabling PHP 5.4 in Windows Azure Web Sites, when we enabled the ability to bring-you-own-runtime to Windows Azure Web Sites. This is still a valid solution if you would like to manage your own PHP.ini file, or if you would like to ensure that you are using a specific build of PHP.

It’s exciting to announce that Windows Azure Web Sites now has PHP 5.4 ready to be enabled in your Web Sites.

Even though PHP 5.4 is available PHP 5.3 is still enabled by default.

image

Enable Native PHP 5.4 in Windows Azure Web Sites

After Creating a Windows Azure Web Site, navigate into the Web Site details page and select the CONFIGURE tab. Under the framework section you will see PHP VERSION, select the box containing 5.4, it will turn purple notifying that there is an unsaved change.

image

At the bottom of the browser viewport you will find the TASK DRAWER, which would have changed to include a SAVE button. Click the SAVE button to enable PHP 5.4 for your Windows Azure Web Site.

image

Once the change has been saved, you’ll be greeted by this nice little success notice.

image

Finally, you will also notice that the purple indicator has now changed back to blue on the PHP 5.4 box.

image

You are now ready to deploy PHP 5.4 applications to Windows Azure Web Sites.

Happy Clouding!

Windows AzureConf is Tomorrow!

Windows AzureConf

Three years ago, I began learning about this thing called “The Cloud” at that point in time I made a decision, much like I made as a teenager to get into Web Development in the first place. The thought that lead me down this career path was “Huh, this web thing is really going to take off, I need to be a part of it.” When I heard about Cloud Computing a similar thought ran through my mind, “Wow, this cloud thing is really cool, this is definitely the way of the future.

A year into working with Windows Azure, I urged other developers to start researching the cloud [Get Started for Free] as it was still early enough to be ahead of the curve and set themselves out from the rest. Enter Windows AzureConf.

I cannot say for certain if I influenced any of these individuals in particular , but what I can say is they have also identified that the Cloud was future. Featuring a Keynote from Scott Guthrie (The Gu) as well as presentations from the Windows Azure Community drawing from their own Real-World experience with Windows Azure.

Join us for Windows AzureConf

In June we launched a number of additional features and services in to Windows Azure’s offerings, since then we have added a great deal more as highlighted in Satya Nadella’s Day 2 Keynote Address at Build.

What will be covered at Windows AzureConf

Windows AzureConf will cover a wide variety of topics including:

  • HTML5
  • WebSockets
  • Windows Azure Media Services
  • Deployment
  • Keeping Costs low
  • SignalR
  • Windows Azure Mobile Services
  • Continuous Delivery
  • Building Cloud-Scale Applications
  • Node.js
  • Compliance
  • Messaging Architectures

How can I get started?

There are a number of ways to get started with Windows Azure including the Windows Azure Training Kit, tutorials on WindowsAzure.com and of course reading the blogs of our community members:

Speaker Name Twitter Blog
Andy Cross @AndyBareWeb blog.elastacloud.com
Sasha Goldshtein @goldshtn blog.sashag.net
Rick Garibay @rickggaribay rickgaribay.net
Mihai Tataran @mihai_tataran www.avaelgo.ro
Eric Boyd @ericdboyd www.ericdboyd.com
Panagiotis Kefalidis @pkefal www.kefalidis.me
Michael Collier @MichaelCollier www.MichaelSCollier.com
Magnus Martensson @noopman magnusmartensson.com

Find more great Windows Azure Community Members on the MVP Site.

Windows Azure Cloud Service or Web Site: Where am I Deployed?

Recently, I came across someone trying to figure out where their code was deployed between Windows Azure Web Sites and Windows Azure Cloud Services. There are many things that you may want to wrap discovery code around between deploying to Cloud Services and Web Sites. One such example that comes to mind is use of LocalStorage in Cloud Services over writing directly to disk in Web Sites.

Non .NET Example with Environment Variables

In Non .NET Languages such as PHP or Node.js you may not have a standard configuration location or you may find the implementation of Environment  Variables more convenient. In a past article I outlined how to read App Settings from the App Settings section of the Windows Azure Management Portal, which explained that App Settings configured in such a way are exposed as Environment Variables.

Cloud Services also have a way to configure custom Environment Variables in the Service Definition (CSDEF) file which is packaged up with a Cloud Service Package (CSPKG). Considering both Cloud Services and Windows Azure Web Sites enable you to expose Environment Variables this is consistent way to share information in either deployment method.

Configuring Environment Variables in Web Sites Portal

Configuring Environment Variables in Cloud Services


Environment Variable in Action

PHP


Node.js


ASP.NET Example using Web.config

In ASP.NET there is the concept of a web.config file. This is an xml based file which is used for storing configuration settings which are specific to a deployment. It is easy to pivot on environment by providing transforms of the web.config file. Let’s assume we have 3 environments Local, WebSites and CloudService.

This will yield three configuration transforms which upon build will roll up to the base web.config:

  • web.local.config
  • web.websites.config
  • web.cloud.config

Creating an App Setting

An App Setting is a Key/Value pair configured in the <appsettings /> element within the web.config file.

Web.config

Application Configuration File

We’ll set this appsettings to a value appropriate for debugging.


Web.local.config

Configuration Transform

We will provide a replacement element for the appsettings for our local test environment.


Web.websites.config

Configuration Transform

We will provide a replacement element for the appsettings for Windows Azure Web Sites.


Web.cloud.config

Configuration Transform

We will provide a replacement element for the appsettings for a Windows Azure Cloud Service.


AppSetting in Action


Conclusion

Depending on your development language or your scenario [as the Environment Variable route would work for ASP.NET as well] you can quickly and easily setup a way to verify which Environment you are deployed to be it Local Test, Windows Azure Web Sites, Windows Azure Cloud Services or any other environment you may have.

Stay Cloudy my Friends…

Windows Azure Training Kit Update Released – August 2012

Today, My team has released a new drop of the Windows Azure Training Kit, it’s available for download now!

What is the Windows Azure Training Kit?

The Windows Azure Training Kit (WATK) is one of the best ways to learn, practice or teach how to leverage Windows Azure and it’s supporting services.

Official Description

Windows Azure Training Kit includes a comprehensive set of technical content to help you learn how to use Windows Azure.

What’s new in the Windows Azure Training Kit?

This release [August 2012] of WATK includes 41 hands-on labs and 35 presentations.

Hands-on Labs

We have pulled in some changes from our GitHub Repository and addressed a number of bug fixes for our hands-on labs for this release. Feel free to Report Issues if you run across a problem in a hands-on lab or presentation.

Presentations

This release introduces a new agenda for Windows Azure DevCamps which contains 7 new presentations:

  • DevCamps Keynote
  • DevCamps Websites
  • DevCamps Cloud Services
  • DevCamps Virtual Machines
  • DevCamps Data
  • DevCamps Windows 8 + Windows Azure
  • DevCamps Windows Phone + Windows Azure

In addition to the new agenda, the following presentations were added to the foundation agenda:

  • Security & Identity
  • Building Scalable, Global and Highly Available  Web Apps
  • Windows Azure SQL Database
  • Windows Azure SQL Federations
  • Windows Azure Reporting
  • Windows Azure Data Sync

Have any feedback?

I’d love to hear any feedback that you have in regards to our training kit. Please leave a comment below.

Stay Cloudy my Friends…

Getting Started with PHP on Windows Azure Web Sites

Windows Azure | Flexible. Open. Rock Solid.

Windows Azure Web Sites (WAWS) is a highly scalable cloud environment build for speed. Windows Azure Web Sites brings down the barriers of Cloud Deployment allowing you do deploy what you want (Support for ASP.NET, PHP & Node.js),  how you want (FTP, Git, TFS, WebDeploy).

In this post I would like to highlight some simple optimizations for  running a PHP Web Site within the Windows Azure Web Sites environment.

Strap on your Tool Belt…

There’s nothing a developer likes more than some a few tools to make the job a little easier. Windows Azure has simplified the process of getting the right tools for the job, to take this one step further, we provide installers for our tools for use on Linux, Mac and/or Windows.

Develop using Windows Azure Services

Visit the PHP Developer Center to install the PHP SDK for Windows Azure.

Manage your Windows Azure Services

You can manage your Windows Azure services all from the comfort of your favorite Command-Line. Visit the Manage downloads page to Get the tools you need. Fast.

In addition to providing Command-Line tools, Windows Azure services can also be managed directly from the Windows Azure Management Portal. The new Windows Azure Management Portal has been completely redesigned in HTML5 which enables it to be used in a variety of devices including Windows Phone and iPad. For Guides on how to navigate the Management Portal specifically related to WAWS, visit the Web Sites page of the Manage Services section on WindowsAzure.com.

Now for Something You’ll Really Enjoy…

In a world that demands instant gratification, performance is paramount, your Web Site needs to be able to deliver in a time of need. Even thought Windows Azure Web Sites has no issues being performing it’s still crucial that we think about optimizing for the best possible result. Luckily the team which built Windows Azure Web Sites has already done an amazing job delivering an environment which follows the Best Practices for running PHP on IIS.

Learning more about the Windows Azure Web Sites Environment

To better understand what is enabled by default in the PHP runtime on Windows Azure Web Sites, create a file called info.php which contains the following:

All of the Server Configuration Information you will need to understand what is capable in Windows Azure Web Sites in the context of PHP.

Installed PHP Modules

php_mysql.dll MySQL Driver for PHP
php_mysqli.dll Improved MySQL Driver for PHP
php_mbstring.dll Multibyte String [Encoding]
php_gd2.dll Image Processing and Creation Library
php_gettext.dll Native Language Support (Globalization & Localization)
php_curl.dll Protocol Support
php_exif.dll Image Metadata
php_xmlrpc.dll Remote Procedure Call
php_openssl.dll SSL Support
php_soap.dll SOAP Protocol
php_pdo_mysql.dll PHP Data Objects for MySQL
php_pdo_sqlite.dll PHP Data Objects for SQLite
php_imap.dll Mail Server Support [IMAP, POP3, NNTP]
php_tidy.dll HTML Document Manipulation
php_wincache.dll Windows Cache [Caches: Opcode, Files, File Paths, User Caching and Session Handling]
php_sqlsrv.dll MS SQL Server Driver for PHP (includes Windows Azure SQL Database Support)
php_pdo_sqlsrv.dll PHP Data Objects for MS SQL Server

Some of those settings don’t suit my needs, what do I do now?

In the event that some of the settings in the php.ini don’t suit your needs DON’T PANIC.

Windows Azure Web Sites allows .user.ini files, which allow you to set certain php.ini configuration values.

One caveat to the .user.ini file is that it will not allow you to install additional modules.

If your application requires additional modules than the ones listed above, you would probably want to look at Windows Azure’s Virtual Machine or Cloud Service offerings.

Debugging PHP in Windows Azure Web Sites

Every developer will inevitably at some point need to debug some code, it’s just a fact of life. If you look at the output from phpinfo() you’ll notice that errors are logged, but not displayed in the browser, which would significantly slow down developer productivity. Not to worry, here is a .user.ini file which will help you with debugging your PHP applications.

Note: Remove the [debug] from the file name.

Important Setting for Accepting Content in Windows Azure Web Sites

When moving my blog to WordPress on Windows Azure Web Sites, I needed to import my BlogML export from BlogEngine.Net unfortunately for me the file size was greater than the default 2MB. Luckily, Brian Swan wrote a post on Configuring PHP in Windows Azure Web Sites with .user.ini files which outlines how to increase the upload_max_filesize to 10MB (I’ve decided that 12MB  is my preferred upload_max_filesize).

Optimize web.config Settings for PHP

If you take a look at this post by Maarten Balliauw on Tweaking Windows Azure Web Sites you will see the two files which provide IIS the base configuration applicationhost.config and webroot.config. Maarten was investigating how to turn on additional HTTP Verbs in Windows Azure Web Sites for a Custom WebDav server. Seeing how more and more applications are using REST, it seems fitting that we enable the majority of HTTP Verbs by default so our application can leverage them.

In addition to adding HTTP Verbs, limiting the list of Default Documents that IIS must rotate through will help optimize page load times. With these two optimizations I have started a web.config starting point for PHP applications on Windows Azure Web Sites.

Note: This post reflects the original state of this file, which is hosted on GitHub and  may change overtime.

Migrating from Apache to Windows Azure Web Sites

If you are currently running an application Apache Web Server and would like to migrate your application Windows Azure Web Sites it’s completely possible, it’s even possible to translate your .htaccess file content to IIS web.config, or if you have a Windows machine, you can use the IIS Rewrite tool to Import mod_rewrite rules into IIS (then copied from the xml view into your web.config file).