Skip to content

Commit 53f13ca

Browse files
committed
Tweaks
1 parent ba571f3 commit 53f13ca

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

playground/AzureStorageEndToEnd/AzureStorageEndToEnd.ApiService/Program.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,29 @@
1212
builder.AddKeyedAzureBlobContainerClient("foocontainer");
1313

1414
builder.AddAzureQueueClient("queues");
15+
builder.AddKeyedAzureQueueClient("myqueue");
1516

1617
var app = builder.Build();
1718

1819
app.MapDefaultEndpoints();
1920

20-
app.MapGet("/", async (BlobServiceClient bsc, QueueServiceClient qsc, [FromKeyedServices("foocontainer")] BlobContainerClient keyedContainerClient1) =>
21+
app.MapGet("/", async (BlobServiceClient bsc, QueueServiceClient qsc, [FromKeyedServices("foocontainer")] BlobContainerClient bcc, [FromKeyedServices("myqueue")] QueueClient qc) =>
2122
{
2223
var blobNames = new List<string>();
2324
var blobNameAndContent = Guid.NewGuid().ToString();
2425

25-
await keyedContainerClient1.UploadBlobAsync(blobNameAndContent, new BinaryData(blobNameAndContent));
26+
await bcc.UploadBlobAsync(blobNameAndContent, new BinaryData(blobNameAndContent));
2627

2728
var directContainerClient = bsc.GetBlobContainerClient(blobContainerName: "test-container-1");
2829
await directContainerClient.UploadBlobAsync(blobNameAndContent, new BinaryData(blobNameAndContent));
2930

3031
await ReadBlobsAsync(directContainerClient, blobNames);
31-
await ReadBlobsAsync(keyedContainerClient1, blobNames);
32+
await ReadBlobsAsync(bcc, blobNames);
3233

34+
// This will check the queue exists.
3335
var queue = qsc.GetQueueClient("myqueue");
34-
await queue.CreateIfNotExistsAsync();
35-
await queue.SendMessageAsync("Hello, world!");
36+
37+
await qc.SendMessageAsync("Hello, world!");
3638

3739
return blobNames;
3840
});

playground/AzureStorageEndToEnd/AzureStorageEndToEnd.AppHost/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
blobs.AddBlobContainer("mycontainer2", blobContainerName: "test-container-2");
1414

1515
var queues = storage.AddQueues("queues");
16+
var myqueue = queues.AddQueue("myqueue", queueName: "my-queue");
1617

1718
var storage2 = builder.AddAzureStorage("storage2").RunAsEmulator(container =>
1819
{
@@ -25,7 +26,8 @@
2526
.WithExternalHttpEndpoints()
2627
.WithReference(blobs).WaitFor(blobs)
2728
.WithReference(blobContainer2).WaitFor(blobContainer2)
28-
.WithReference(queues).WaitFor(queues);
29+
.WithReference(queues).WaitFor(queues)
30+
.WithReference(myqueue).WaitFor(myqueue);
2931

3032
#if !SKIP_DASHBOARD_REFERENCE
3133
// This project is only added in playground projects to support development/debugging

src/Aspire.Hosting.Azure.Storage/AzureQueueStorageResource.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class AzureQueueStorageResource(string name, AzureStorageResource storage
1616
IResourceWithParent<AzureStorageResource>,
1717
IResourceWithAzureFunctionsConfig
1818
{
19-
// NOTE: if ever these contants are changed, the AzureBlobStorageContainerSettings in Aspire.Azure.Storage.Blobs class should be updated as well.
19+
// NOTE: if ever these contants are changed, the AzureStorageQueueSettings in Aspire.Azure.Storage.Queues class should be updated as well.
2020
private const string Endpoint = nameof(Endpoint);
2121
private const string QueueName = nameof(QueueName);
2222

@@ -69,10 +69,10 @@ void IResourceWithAzureFunctionsConfig.ApplyAzureFunctionsConfiguration(IDiction
6969
/// <summary>
7070
/// Converts the current instance to a provisioning entity.
7171
/// </summary>
72-
/// <returns>A <see cref="global::Azure.Provisioning.Storage.BlobService"/> instance.</returns>
73-
internal global::Azure.Provisioning.Storage.BlobService ToProvisioningEntity()
72+
/// <returns>A <see cref="global::Azure.Provisioning.Storage.QueueService"/> instance.</returns>
73+
internal global::Azure.Provisioning.Storage.QueueService ToProvisioningEntity()
7474
{
75-
global::Azure.Provisioning.Storage.BlobService service = new(Infrastructure.NormalizeBicepIdentifier(Name));
75+
global::Azure.Provisioning.Storage.QueueService service = new(Infrastructure.NormalizeBicepIdentifier(Name));
7676
return service;
7777
}
7878
}

src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.StorageQueueComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected override IAzureClientBuilder<QueueClient, QueueClientOptions> AddClien
2424
{
2525
if (string.IsNullOrEmpty(settings.QueueName))
2626
{
27-
throw new InvalidOperationException($"The connection string '{connectionName}' does not exist or is missing the container name.");
27+
throw new InvalidOperationException($"The connection string '{connectionName}' does not exist or is missing the queue name.");
2828
}
2929

3030
var connectionString = settings.ConnectionString;

src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static void AddKeyedAzureQueueClient(
9191
/// <param name="configureClientBuilder">
9292
/// An optional method that can be used for customizing the <see cref="IAzureClientBuilder{TClient, TOptions}"/>.
9393
/// </param>
94-
/// <remarks>Reads the configuration from "Aspire:Azure:Storage:Blobs" section.</remarks>
94+
/// <remarks>Reads the configuration from "Aspire:Azure:Storage:Queues:{name}" section.</remarks>
9595
/// <exception cref="InvalidOperationException">
9696
/// Neither <see cref="AzureStorageQueuesSettings.ConnectionString"/> nor <see cref="AzureStorageQueuesSettings.ServiceUri"/> is provided.
9797
/// - or -
@@ -125,7 +125,7 @@ public static void AddAzureQueue(
125125
/// <param name="configureClientBuilder">
126126
/// An optional method that can be used for customizing the <see cref="IAzureClientBuilder{TClient, TOptions}"/>.
127127
/// </param>
128-
/// <remarks>Reads the configuration from "Aspire:Azure:Storage:Blobs" section.</remarks>
128+
/// <remarks>Reads the configuration from "Aspire:Azure:Storage:Queues:{name}" section.</remarks>
129129
/// <exception cref="InvalidOperationException">
130130
/// Neither <see cref="AzureStorageQueuesSettings.ConnectionString"/> nor <see cref="AzureStorageQueuesSettings.ServiceUri"/> is provided.
131131
/// - or -

tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureStorageExtensionsTests.ResourceNamesBicepValid.verified.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ resource blobs 'Microsoft.Storage/storageAccounts/blobServices@2024-01-01' = {
2626
parent: storage
2727
}
2828

29+
resource queues 'Microsoft.Storage/storageAccounts/queueServices@2024-01-01' = {
30+
parent: storage
31+
}
32+
2933
resource myContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2024-01-01' = {
3034
name: 'my-blob-container'
3135
parent: blobs

0 commit comments

Comments
 (0)