by david via t h e D a v i d A i k e n on 2/9/2009 2:45:00 PM
Whilst looking for a simple asp.net application I could “migrate” to Windows Azure, I stumbled upon the Small Business Starter Kit at the ASP.NET web site - http://www.asp.net/downloads/starter-kits/small-business/.
One of the features of the Small Business Starter Kit is the Provider Model. You can either use an SQL or XML data source. Bingo I thought. An XML data source! All I’d need to do with this is load the XML data from Windows Azure Blob storage instead of the file system and it would be running on Windows Azure!
Here is what I did (I assume you are using Visual Studio Web Developer Express & have the Windows Azure SDK & Tools installed):
Now you can hit F5, and the site runs in Windows Azure. Magic. Clicking on Items, or People will give you errors, because we are trying to load the xml data from the file system. (Actually the error is because the files aren’t copied as part of the output. We could fix that, but really we want them in blob storage so they can be updated at runtime.)
The next step is to update the XML Provider to read the xml files from Blob storage, rather than the file system. Here are the steps I took:
Hitting F5 runs the site, and reads the items, people etc. from blob storage.
Here is my serviceconfiguration.cscsf file:
<?xml version="1.0"?>
<ServiceConfiguration serviceName="starterbktest" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="WebRole">
<Instances count="1"/>
<ConfigurationSettings>
<Setting name="AccountName" value="devstoreaccount1" />
<Setting name="AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" />
<Setting name="BlobStorageEndpoint" value="http://127.0.0.1:10000" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
And here is my changed ReadAndValidateXml method:
public static DataSet ReadAndValidateXml(string xmlFilePath, string schemaFilePath)
{
xmlFilePath = Path.GetFileName(xmlFilePath).ToLower();
schemaFilePath = "schemas\\" + Path.GetFileName(schemaFilePath).ToLower();
DataSet dataSet = null;
BlobStorage store = BlobStorage.Create(StorageAccountInfo.GetDefaultBlobStorageAccountFromConfiguration());
BlobContainer container = store.GetBlobContainer("sbkit");
BlobContents xmlFileBlob = new BlobContents(new MemoryStream());
BlobContents xmlSchemaBlob = new BlobContents(new MemoryStream());
container.GetBlob(xmlFilePath, xmlFileBlob, false);
container.GetBlob(schemaFilePath, xmlSchemaBlob, false);
byte[] ook = xmlFileBlob.AsBytes();
byte[] schemaook = xmlSchemaBlob.AsBytes();
dataSet = new DataSet();
dataSet.ReadXmlSchema(new MemoryStream(schemaook));
dataSet.ReadXml(new MemoryStream(ook), XmlReadMode.IgnoreSchema);
return dataSet;
}
The first few lines rework the paths for the files. The rest is simple Blob storage code to read blobs.
For those with more than enough thiings to do already, here is the source code zip.
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS
Original Post: Small Business Starter Kit on Windows Azure
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.