title: Creating an Azure CloudStorageAccount from a TokenCredential using a token obtained via Azure MSI
body: <p>I am attempting to create a <code>CloudStorageAccount</code> using an access token generated via MSI on Azure to be used in the Serilog Azure Blob Storage sink. I am getting a token and creating the account using the following</p>
  
  <pre><code>var tokenProvider = new AzureTokenProvider();
  var token = await tokenProvider.GetAccessTokenAsync("https://storage.azure.com");
  var tokenCredential = new TokenCredential(token);
  var storageCredential = new StorageCredential(tokenCredential);
  var account = new CloudStorageAccount(storageCredential, "accountnamehere", "core.windows.net", true);
  </code></pre>
  
  <p>I then pass this account to the Serilog `LoggerConfiguration' as such</p>
  
  <pre><code>Log.Logger = new LoggerConfiguration()
      //other stuff
      .WriteTo.AzureBlobStorage(new JsonFormatter(), account, //other settings)
      .CreateLogger()
  </code></pre>
  
  <p>However, this never will write to the blob. My Azure account has both Contributor directly, and inherits Storage Blob Data Contributor from a group. The Azure VM I am working on also has Storage Blob Data Contributor to this storage account. However, in dev the credentials it is using are mine. </p>
  
  <p>When I use the account key the blob is written to without issue, so something is either not correct with how I am generating the <code>CloudStorageAccount</code> or the permissions in Azure are not set up correctly, I am just not sure which. </p>