|
If you've been trying to get the ASP.NET providers working on the November 2009 CTP of Windows Azure then you may have run into a snag, or a couple snags if you're using Visual Studio 2010.
First of all, if you're using Visual Studio 2010 Beta 2, then you're going to need to either up-convert the AspProviders project. For this, you want to go and grab the AspProviders (VS2008) sample from the Azure Code Samples home page. Once you've got it, you can either compile it in Visual Studio 2008 or, if you're coding in VS2010 Beta 2, you can either reference the compiled binary directly or just up-convert the project to VS2010 Beta 2.
The new AspProviders sample uses the new Microsoft.WindowsAzure.StorageClient library that now comes with the new version of the SDK. This version of the storage client is more robust, better supported, and more efficient than the sample storage client from previous versions of the SDK.
First, you're going to want to rig up your Web.config to use the new provider with elements like this:
<membership defaultProvider="TableStorageMembershipProvider"
userIsOnlineTimeWindow = "20">
<providers>
<clear/>
<add name="TableStorageMembershipProvider"
type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageMembershipProvider"
description="Membership provider using table storage"
applicationName="AspProvidersDemo"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
requiresUniqueEmail="true"
passwordFormat="Hashed"
/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="TableStorageRoleProvider"
cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="30"
cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration = "true"
cookieProtection="All" >
<providers>
<clear/>
<add name="TableStorageRoleProvider"
type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageRoleProvider"
description="Role provider using table storage"
applicationName="AspProvidersDemo"
/>
</providers>
</roleManager>
<!--<profile enabled="true" defaultProvider="TableStorageProfileProvider"
inherits="UserProfile">
<providers>
<clear/>
<add name="TableStorageProfileProvider"
type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageProfileProvider"
description="Profile provider using structured storage"
applicationName="AspProvidersDemo"
/>
</providers>
--><!--
<properties>
<add name="Country" type="string"/>
<add name="Gender" type="string"/>
<add name="Age" type="Int32"/>
</properties>
--><!--
</profile>-->
<sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
<providers>
<clear />
<add name="TableStorageSessionStateProvider"
type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider"
applicationName="AspProvidersDemo"
/>
</providers>
</sessionState>
You might have noticed that I've commented out the profile provider. This is because if you use the profile provider, you might run into a problem where an exception is thrown at runtime (during app startup) that complains about you attempting to access an unloaded AppDomain. Microsoft is aware of this and I'm expecting to shortly see a workaround, fix, or an update to the SDK. In the meantime, just comment out the profile provider and you'll be able to use the provider samples as-is.
Keep checking back here for more blog posts on using the new Nov 09 CTP of Windows Azure and any potential updates/fixes to this particular issue with the profile provider.
You also need to add the AccountName, AccountSharedKey, and endpoints in
<appSettings>, right?
Yes, those are required for the AspProviders sample, regardless of how
you're using it or what development environment (VS08 or VS10) you're
using.
AspProviders from earlier Azure builds didn't require the credentials to be
in <appSettings \>. I wonder how to get around that. Also, I wonder
how to have AspProviders simply read the new DataConnectionString in
ServiceConfiguration.cscfg.
All versions of the AspProviders sample read the credentials from config -
using an elaborate and (IMHO) incorrect method to scan both your web.config
and your service configuration file. This applies to old as well as new.
I should have been more clear. Previous versions of AspProviders could
read from ServiceConfiguration.cscfg, but the November version appears to
only read from web.config.
The AspProviders thing is purely a sample and Microsoft is continually
working on it. I also noticed that it doesn't seem to read the information
out of the service configuration file. Here's my thought: I'm OK using
AspProviders in test..but when i put an application to production, you can
bet I won't be using the Microsoft _sample_ code when I put it there.