public async Task Setup() { // Set up receiver queue on 2nd storage account var queueServiceClient = new QueueServiceClient(Utilities.GetEnvConfiguredConnectionString2()); _ = await queueServiceClient.CreateQueueAsync(ReceiverName); _ = await queueServiceClient.CreateQueueAsync(AuditName); _ = await queueServiceClient.CreateQueueAsync("error"); }
public async Task SharedAccessSignatureAuthAsync() { // Create a service level SAS that only allows reading from service // level APIs AccountSasBuilder sas = new AccountSasBuilder { // Allow access to queues Services = new AccountSasServices() { Queues = true }.ToString(), // Allow access to the service level APIs ResourceTypes = new AccountSasResourceTypes() { Service = true }.ToString(), // Allow read access Permissions = new AccountSasPermissions() { Read = true }.ToString(), // Access expires in 1 hour! ExpiryTime = DateTimeOffset.UtcNow.AddHours(1) }; // Create a SharedKeyCredential that we can use to sign the SAS token StorageSharedKeyCredential credential = new StorageSharedKeyCredential(StorageAccountName, StorageAccountKey); // Build a SAS URI UriBuilder sasUri = new UriBuilder(StorageAccountQueueUri) { Query = sas.ToSasQueryParameters(credential).ToString() }; // Create a client that can authenticate with the SAS URI QueueServiceClient service = new QueueServiceClient(sasUri.Uri); // Make a service request to verify we've succesfully authenticated await service.GetPropertiesAsync(); // Try to create a new container (which is beyond our // delegated permission) StorageRequestFailedException ex = Assert.ThrowsAsync <StorageRequestFailedException>( async() => await service.CreateQueueAsync(Randomize("sample-queue"))); Assert.AreEqual(403, ex.Status); }
public async Task GetQueuesAsync_Prefix() { QueueServiceClient service = GetServiceClient_SharedKey(); var prefix = "aaa"; var queueName = prefix + GetNewQueueName(); QueueClient queue = (await service.CreateQueueAsync(queueName)).Value; // Ensure at least one queue try { AsyncPageable<QueueItem> queues = service.GetQueuesAsync(prefix: prefix); IList<QueueItem> items = await queues.ToListAsync(); Assert.AreNotEqual(0, items.Count()); Assert.IsTrue(items.All(c => c.Name.StartsWith(prefix))); Assert.IsNotNull(items.Single(c => c.Name == queueName)); } finally { await service.DeleteQueueAsync(queueName); } }
static async Task CreateQueueAsync(string connectionString, string queueName) { QueueServiceClient serviceClient = new QueueServiceClient(connectionString); QueueClient queue = await serviceClient.CreateQueueAsync(queueName); }
public static async Task CreateAsync(string account, string key, string queueName) { QueueServiceClient client = new QueueServiceClient(Client.GetConnectionString(account, key)); await client.CreateQueueAsync(queueName); }
public async Task CreateQueueAsync_AlreadyExistsWithDifferentMetadata_ReportsConflictProperly() { IQueueServiceClient client = new QueueServiceClient(_accountSettings); var queueName = GenerateSampleQueueName(); _util.CreateQueue(queueName); await client.CreateQueueAsync(queueName, new Dictionary<string, string> { { "SampleKey", "SampleValue" } }); // expects exception }
public async Task CreateQueueAsync_ValidName_CreatesQueue() { IQueueServiceClient client = new QueueServiceClient(_accountSettings); var queueName = GenerateSampleQueueName(); await client.CreateQueueAsync(queueName); _util.AssertQueueExists(queueName); }