Using the Sample Windows Azure ASP.NET Providers


Previously, the sample Windows Azure ASP.NET providers were included in the samples folder that was installed with the SDK.


As of the November 2009 release of the Windows Azure Tools & SDK, this is no longer the case.  The samples are available online at http://code.msdn.microsoft.com/windowsazuresamples.


To use these samples:


1. Download the samples and unzip (These are no longer included as part of the samples installed to the SDK folder)


2. Add the AspProviders/Lib/AspProviders.csproj project to the solution by right clicking on the solution and selecting Add | Existing Project… and navigating to the AspProviders.csproj file.


3. Add a reference from your ASP.NET MVC 2 Web role to the AspProviders sample library by right clicking on the “references” folder in the ASP.NET MVC project and selecting “Add Reference…”


image


and selecting the AspProviders assembly:


image


4. Open the web.config file and add/change the providers. 


You can set the applicationName appropriately for your application. 


These sections are added under the system.web element. Note that I’m still tracking down some issues I’m seeing with the profile provider, will update this post when I know more.


Membership Provider:

    <membership defaultProvider=TableStorageMembershipProvideruserIsOnlineTimeWindow = 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>


Role Manager Provider:

  <roleManager enabled=truedefaultProvider=TableStorageRoleProvidercacheRolesInCookie=truecookieName=.ASPXROLEScookieTimeout=30
cookiePath=/cookieRequireSSL=falsecookieSlidingExpiration = true
cookieProtection=All>
<
providers>
<
clear/>
<
add name=TableStorageRoleProvider
type=Microsoft.Samples.ServiceHosting.AspProviders.TableStorageRoleProvider
description=Role provider using table storage
applicationName=AspProvidersDemo
/>
</
providers>
</
roleManager>

Session State Provider:

        <sessionState mode=CustomcustomProvider=TableStorageSessionStateProvider>
<
providers>
<
clear />
<
add name=TableStorageSessionStateProvider
type=Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider
applicationName=AspProvidersDemo
/>
</
providers>
</
sessionState>

Change the existing appSettings element and the folllowing provider configuration:

  <appSettings>
<
add key = TableStorageEndpointvalue=http://127.0.0.1:10002/devstoreaccount1/>
<
add key = BlobStorageEndpointvalue=http://127.0.0.1:10000/devstoreaccount1/>
<
add key = AccountNamevalue=devstoreaccount1/>
<
add key = AccountSharedKeyvalue=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==/>

<!– provider configuration –>
<!–
When using the local development table storage service only the default values given
below will work for the tables (Membership, Roles and Sessions) since these are the names
of the properties on the DataServiceContext class
–>
<
add key = DefaultMembershipTableNamevalue=Membership/>
<
add key = DefaultRoleTableNamevalue=Roles/>
<
add key = DefaultSessionTableNamevalue=Sessions/>
<
add key = DefaultProviderApplicationNamevalue=ProviderTest/>
<
add key = DefaultProfileContainerName/>
<
add key = DefaultSessionContainerName/>
</
appSettings>


You can now remove the “ApplicationServices” connection string as all of the providers that referenced it are gone.


6. Hit F5 to debug the application and your application is now using the sample ASP.NET providers that run against Windows Azure storage!


What’s next?  You can bet that we’ll put some more work into these providers to make them better and potentially even provide them as a real library. 


Stay tuned.

Comments (14)

  1. clement.gutel@gmail.com says:

    Hi.

    I’ve just updated my solution to use the new samples of nov 2009 and it looks like there is a problem with the hashing of password.

    Subsequent hashing of the same password with the same salt seem to yield different hash.

    Therefore it’s impossible to login succesfully !

    Setting the passwordFormat to clear solved the issue.

    Is it a known issue ? It seems like really basic functionality so maybe I missed something.

  2. Clement – can you provide me a code sample of the issue you are seeing?

  3. LukaszN says:

    Hi,

    I’ve been trying to get this sample to work using development storage. It seems like blobs with session data are not being removed from the container after user logs out (Session.Abandon() is called).

    Debugging shows that IEnumerable<IListBlobItem> object returned by CloudBlobContainer.ListBlobs() times out when trying to enumerate over blobs to be deleted.

    Has anyone experienced similar behavior?

  4. azurebright says:

    Yes, it seems that session data stored in the blobs, are not being removed, and just keeps on growing and growing.

  5. paulenfield — thank you, I’ve updated the link.

  6. azurebright says:

    Hello jnak!

    Do you have any information, on what’s happening with the AspProvider sample, any updates coming soon or anything?

  7. azurebright – it’s on the list, no plans I can share at this point.

  8. Feels wired to reference "Samples". I would love to see MS opensource these providers, or at least name their namespaces better.. Not to mention the "googleblity", seems that google ignores code.msdn.microsoft.com completely

  9. Hi Carl, great feedback.  We're in the process of figuring out how to support ASP.NET providers in a first class manner and your feedback helps us to prioritize the scenario.

  10. Vijay Arora says:

    I am facing the error while implementing the aspprovider session. It gives me error the following line that it can not seriliazie the objects.

    ((SessionStateItemCollection)store.Items).Serialize(writer1);

    I don't understand what is happening behind the scenes.

  11. Vijay Arora says:

    I am getting the following error in the application.

    Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

    Could you please provide the solution.

  12. Vijay – off hand it sounds like you are trying to save an object that doesn't support serialization.  Does the problem occur with the standard providers and SQL Express or is this related only to using the Azure providers?

  13. Hi,

    it is possible to deploye html5 pahes in windows azure?

    it's possible plz tell me process

    plz help me

Skip to main content