Category: azure

MVC Browser history provider for azure–trying an implementation for 3 hours

first, implement  IBrowserUserHistoryRepository  – that means implement:

public void Save(IEnumerable<BrowserUserHistoryData> history)

 

Azure have PartitionKey/RowKey – I have to add a new class.

Also or connectiing, I have to put

 

connectionString="UseDevelopmentStorage=true;" /

 

I tried to add a bulk history :
tableHistory.ExecuteBatch(batchOperation);
The result was:
Unexpected response code for operation : 0
Magic: 
<add key="TableStorageEndpoint" value="http://127.0.0.1:1002/"/>
And one hour has been gone.
Run dsinit to have storage emulator:
No connection could be made because the target machine actively refused it 127.0.0.1:10002

modified code to old Azure code:

now the answer was:

One of the request inputs is out of range.

http://msdn.microsoft.com/en-us/library/dd135715.aspx – All letters in a container name must be lowercase.

Tried that – same result:

One of the request inputs is out of range.

Maybe timestam is wrong? No…

Now debug with Fiddler :

http://sepialabs.com/blog/2012/02/17/profiling-azure-storage-with-fiddler/

image

 

Added to connection string:

 

DevelopmentStorageProxyUri=http://ipv4.fiddler
 And see this in Fiddler :

<d:PartitionKey>zungb4ovunqjd5rtal5ytc3r</d:PartitionKey>

<d:RowKey>http://localhost:2728/</d:RowKey>

: base(UserName, UserName)
 
So the problem is that RowKey does not support url values.
Now , after removing url from the RowKey  - and put username, the error was:

The specified entity already exists

Another hour passes

——————

Now, that it works, thinking about rowkey and partitionkey : no username + url => put date.ToString("yyyyMMdd_HHmmss_tttt")

0:The specified entity already exists.

Oh no, not again?

Look tables =>20121220_064024_AM -  ok, it should be

date.ToString("yyyyMMdd_HHmmss_ffffzzz")

0:The specified entity already exists

Again? debug, please

The real problem:

Forget about sending whole items history - not just not saved ones…
Now it works – kind of

Server Error in ‘/’ Application.


The method or operation is not implemented.

public IEnumerable<KeyValuePair<string, int>> MostUsed(int Count, DateTime? date)
Line 80:         {
Line 81:             throw new NotImplementedException();
Line 82:         }
Line 83: 
-----------
Implementing MostUsed(int Count, DateTime? date) 
Research about filter with data - http://storageextensions.codeplex.com/SourceControl/changeset/view/81826#1914483
Research about GroupBY – not supported!http://msdn.microsoft.com/en-us/library/windowsazure/dd135725.aspx
So now thinking about a way to STORE the data in a convenient format to can retrieve…
 It must take into consideration Count for a date and Count for all dates( date can be null) – AND BOTH THE FACT THAT THE OPERATION WILL BE DONE PER USER.
Time to think – because another hour has passed!
 

Azure tools

Azure storage Explorer : http://azurestorageexplorer.codeplex.com/  – like in VS , but simpler and cleaner

Windows Azure ASP.NET Providers Sample : http://code.msdn.microsoft.com/windowsazure/Windows-Azure-ASPNET-03d5dc14 – utils for fast membership and roles. Small problem on local.

More samples here: http://code.msdn.microsoft.com/windowsazure/

And that will be all , after reading the documentation and understanding the concepts ( for example,if you understand the session problem in azure, then you will find a Session provider in the samples and use it)

Azure

I am working at a new application ( Azure + MVC + logging) and I am having a good time  – when I know resources. This are the steps that works for me:

  1. Azure SDK ( it would be good if you have Sql Server). Now version 1.6, download from http://www.microsoft.com/download/en/details.aspx?id=28045
      1. Optional : run DSInit , http://msdn.microsoft.com/en-us/library/windowsazure/gg433005.aspx , to modify default SqlServer instance
  2. Windows Azure ASP.NET Providers Sample – good to fast use membership in Azure.
      1. for local , the .config keys are

        <add key="AccountName" value="devstoreaccount1" />
            <add key="AccountSharedKey" value=""></add>
            <add key="BlobStorageEndpoint" value="http://127.0.0.1:10000/devstoreaccount1" />
            <add key="TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1" />

      2. for azure, the .config keys are

           <add key="AccountName" value="…………………………" />
          <add key="AccountSharedKey" value="………………"></add>

          <add key="BlobStorageEndpoint" value="https://logcollectorazure.blob.core.windows.net" />
          <add key="TableStorageEndpoint" value="https://logcollectorazure.table.core.windows.net" />

  3. Add Table Storage Provider- either from samples, either from here  http://blogs.msdn.com/b/jnak/archive/2010/01/06/walkthrough-windows-azure-table-storage-nov-2009-and-later.aspx  ( read http://blogs.msdn.com/b/jnak/archive/2008/10/28/walkthrough-simple-table-storage.aspx too)
      1. for local , the .config keys are
      2. <add key="BlobStorageEndpoint" value="http://127.0.0.1:10000/devstoreaccount1" />
        <add key="TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1" />

      3. for azure, the .config keys are

<add key="BlobStorageEndpoint" value="https://logcollectorazure.blob.core.windows.net" />
<add key="TableStorageEndpoint" value="https://logcollectorazure.table.core.windows.net" />

From now, you do have

a) An Membership Provider -  to create users

b) Azure Tables that can be searched with IQueryable .

This is all you need for now. Later you will enquire about caching / session / application. I would post them when I will be programming more. However , for caching I will be starting at http://code.msdn.microsoft.com/windowsazure/Using-AppFabric-Cache-595454bb and for session at http://code.msdn.microsoft.com/windowsazure/Using-AppFabric-Cache-595454bb

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.