by Steve Marx via Steve Marx's blog on 4/29/2010 5:41:57 PM
One of the coolest uses I’ve found for my Windows Azure Hosted Web Core Worker Role is to sync my website with blob storage, letting me change files at will and immediately see the results in the cloud. You can grab the code over on Code Gallery, or a prebuilt package that you can deploy right away.
Here’s a 30-second video showing it in action:
In a typical Windows Azure web role, IIS is configured to host the website contained in your application package. As you may know, this content is in a read-only directory on the virtual machine. That means that to change anything in your website, you need to redeploy your application.
With the Hosted Web Core Worker Role, I can point Hosted Web Core (HWC) at any local directory by just changing applicationHost.config. This means I can have a writable local directory (using local storage resources), and I can populate that directory with the website content I fetch from blob storage. Then it’s just a matter of continually syncing those blobs as they change.
applicationHost.config
The class that does all the work is called OneWayBlobSync. It’s used in WorkerRole.cs like this in OnStart():
OneWayBlobSync
WorkerRole.cs
OnStart()
sync = new OneWayBlobSync( container, RoleEnvironment.GetLocalResource("Websites").RootPath, TimeSpan.FromSeconds(int.Parse( RoleEnvironment.GetConfigurationSettingValue("SyncIntervalInSeconds"))));
and then in Run():
Run()
sync.Start();
Under the hood, this class does the following:
That’s it!
There are a few drawbacks to using this approach:
The bottom line is that I’d hesitate to use this in production. But it’s awesome as a development tool.
You can download the full source code or a prebuilt package over at the Windows Azure Hosted Web Core Worker Role on Code Gallery. With the prebuilt package, you can simply update the configuration file (ServiceConfiguration.cscfg) and deploy. Then you can copy the website to blob storage whenever you’re ready.
ServiceConfiguration.cscfg
Original Post: Update Your Windows Azure Website in Just Seconds by Syncing with Blob Storage
The content of the postings is owned by the respective author. AzureFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on AzureFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.