title: Identity alternative for SQL Azure Federation : are Azure Queues or Service Bus Queues a good choice?
body: <p>As many of developers, I'm looking for a way to integrate my existing app to SQL Azure Federations, and replacing the Identity columns (the primary keys of my tables) is a big problem.</p>
  
  <p>For many reasons, I do NOT want to use GUID for my primary keys (please don't open the debate about the GUID or not, it's not my question : i just don't want a GUID, period).</p>
  
  <p>So I need to build a key provider to replace the "identity" feature of a standard SQL database. I'm using Entity Framework, so I can easily find one place to set the <code>Id</code> value just before the insert (by overriding the <code>SaveChanges</code> method of my <code>ObjectContext</code> class). I just need to find a "not too complicated" implementation for getting the current Id, which is "farm-ready".</p>
  
  <p>I've read this SO post : "<a href="https://stackoverflow.com/questions/9320174/id-generation-for-sharded-database-azure-federated-database">ID Generation for Sharded Database (Azure Federated Database)</a>" and "<a href="http://msdn.microsoft.com/en-us/magazine/gg309174.aspx" rel="nofollow noreferrer">Synchronizing Multiple Nodes in Windows Azure</a> from MSDN Magazine", but this solution sounds a bit complicated for me.</p>
  
  <p>I'm thinking about creating (automatically) one azure queue for each SQL table, which contain a pre-loaded list of consecutive integer. When I want an Id value, I just have to get a message from the queue (which becomes invisible and is deleted on the way), which give me the current available Id.</p>
  
  <p>About the choice between "Windows Azure Queues" and "Windows Azure Service Bus Queues", I prefere "Windows Azure Queues", due to the <a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh767287.aspx" rel="nofollow noreferrer">"high" latency of Service Bus Queues</a>.
  I don't think that the lack of "ordering garantee" of Azure Queues is a problem.</p>
  
  <p><strong>What do you think about that idea of using Azure Queues to provide Id values ?</strong> Do you see any argument to give up that idea ? Do you have a better idea, or even a good practice, to provider integer ids in SQL Azure Federation databases ?
  Thanks.</p>
  
  <p><strong>EDIT :</strong> </p>
  
  <p>Astaykov suggested <a href="http://blog.tatham.oddie.com.au/2011/07/14/released-snowmaker-a-unique-id-generator-for-azure-or-any-other-cloud-hosting-environment/" rel="nofollow noreferrer">SnowMaker</a>. I've finally done a <a href="https://bitbucket.org/jyl2002/snowmaker-compatible-with-azure-storage-lib-v2" rel="nofollow noreferrer">fork of SnowMaker</a> to have a full compatibility with the v2 of the Azure Storage lib.</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Please note that <strong><em>Azure SQL Federation will be retired September 2015</em></strong> with web and business tiers, as explained <a href="http://msdn.microsoft.com/library/azure/dn741330.aspx" rel="nofollow noreferrer">here</a>. But this question remains valid for custom sharding solutions.</p>