title: Azure Storage: How to generate a SAS connection string using .NET SDK
body: <p>I'm currently generating SAS tokens using the <code>Microsoft.WindowsAzure.Storage.CloudStorageAccount</code> class like so:</p>
  <pre><code>var cloudStorageAccount = // create a new CloudStorageAccount
  var sharedAccessAccountPolicy = new SharedAccessAccountPolicy
  {
      Permissions = SharedAccessAccountPermissions.Read | SharedAccessAccountPermissions.Write,
      Services = SharedAccessAccountServices.Blob,
      ResourceTypes = SharedAccessAccountResourceTypes.Object,
      SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),
      Protocols = SharedAccessProtocol.HttpsOnly
  };
  
  var token = cloudStorageAccount.GetSharedAccessSignature(sharedAccessAccountPolicy);
  </code></pre>
  <p>However, this returns a token with a <code>?</code> in front and does not include the blob endpoint. I was looking at this <a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string" rel="nofollow noreferrer">documentation</a> and noticed a SAS looks like below:</p>
  <pre><code>BlobEndpoint=https://storagesample.blob.core.windows.net;
  SharedAccessSignature=sv=2015-04-05&amp;sr=b&amp;si=tutorial-policy-635959936145100803&amp;sig=9aCzs76n0E7y5BpEi2GvsSv433BZa22leDOZXX%2BXXIU%3D
  </code></pre>
  <p>What's neat about this is that I can use it as a connection string to directly initialize a <code>BlockBlobClient</code>.</p>
  <p>How can I generate my token in the above format? I can parse my own and remove the <code>?</code> and then add the <code>BlobEndpoint</code> and <code>SharedAccessSignature</code> keys, but this is manual work and may not function properly in the future. Is there an SDK method that creates a SAS in the format that's shown on Microsoft's documentation?</p>