Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create CloudQueueClient with Local and MSI
// For local Auth with ConnectionString (temporary workaround)
private static CloudQueueClient CreateQueueClient(string connectionString)
var account = CloudStorageAccount.Parse(connectionString);
var queueClient = account.CreateCloudQueueClient();
return queueClient;
// For MSI Auth
private static async Task<CloudQueueClient> CreateQueueClientAsync(string storageAccountName)
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var accessToken = await azureServiceTokenProvider.GetAccessTokenAsync("");
var tokenCredential = new TokenCredential(accessToken);
var storageCredentials = new StorageCredentials(tokenCredential);
var queueClient = new CloudQueueClient(new StorageUri(new Uri($"https://{storageAccountName}")), storageCredentials);
return queueClient;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment