Skip to content

Commit

Permalink
Update README for Azure Hosting projects to fix description of the me… (
Browse files Browse the repository at this point in the history
dotnet#3732)

* Update README for Azure Hosting projects to fix description of the methods to add the resources, and show AddConnectionString as an alternative to use an existing service

* Update src/Components/Aspire.Azure.Messaging.EventHubs/README.md

Co-authored-by: Eric Erhardt <[email protected]>

* Apply suggestions from code review

Co-authored-by: Eric Erhardt <[email protected]>

* Apply suggestions from code review

---------

Co-authored-by: Eric Erhardt <[email protected]>
  • Loading branch information
radical and eerhardt authored Apr 17, 2024
1 parent bafcacd commit 45a54c5
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/Components/Aspire.Azure.AI.OpenAI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ dotnet add package Aspire.Hosting.Azure.CognitiveServices
Then, in the _Program.cs_ file of `AppHost`, add an Azure AI OpenAI service and consume the connection using the following methods:

```csharp
var openai = builder.AddAzureOpenAI("openai");
var openai = builder.ExecutionContext.IsPublishMode
? builder.AddAzureOpenAI("openai")
: builder.AddConnectionString("openai");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(openai);
```

The `AddAzureOpenAI` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:openai` config key. The `WithReference` method passes that connection information into a connection string named `openai` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddAzureOpenAI` method adds an Azure OpenAI resource to the builder. Or `AddConnectionString` can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:openai` config key. The `WithReference` method passes that connection information into a connection string named `openai` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureOpenAIClient("openai");
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Aspire.Azure.Data.Tables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ dotnet add package Aspire.Hosting.Azure.Storage
Then, in the _Program.cs_ file of `AppHost`, add a Table Storage connection and consume the connection using the following methods:

```csharp
var tables = builder.AddAzureStorage("storage").AddTables("tables");
var tables = builder.ExecutionContext.IsPublishMode
? builder.AddAzureStorage("storage").AddTables("tables")
: builder.AddConnectionString("tables");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(tables);
```

The `AddTables` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:tables` config key. The `WithReference` method passes that connection information into a connection string named `tables` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddTables` method will add an Azure Storage table resource to the builder. Or `AddConnectionString` can be used to read the connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:tables` config key. The `WithReference` method passes that connection information into a connection string named `tables` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureTableClient("tables");
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Aspire.Azure.Messaging.EventHubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ dotnet add package Aspire.Hosting.Azure.EventHubs
Then, in the _Program.cs_ file of `AppHost`, add an Event Hubs connection and an Event Hub resource and consume the connection using the following methods:

```csharp
var eventHubs = builder.AddAzureEventHubs("eventHubsConnectionName").AddEventHub("MyHub");;
var eventHubs = builder.ExecutionContext.IsPublishMode
? builder.AddAzureEventHubs("eventHubsConnectionName").AddEventHub("MyHub")
: builder.AddConnectionString("eventHubsConnectionName");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(eventHubs);
```

The `AddAzureEventHubs` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:eventHubsConnectionName` config key. The `WithReference` method passes that connection information into a connection string named `eventHubsConnectionName` in the `MyService` project.
The `AddAzureEventHubs` method adds an Azure Event Hubs Namespace resource to the builder. Or `AddConnectionString` can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:eventHubsConnectionName` config key. The `WithReference` method passes that connection information into a connection string named `eventHubsConnectionName` in the `MyService` project.

NOTE: Even though we are creating an Event Hub using the `AddEventHub` at the same time as the namespace, for this release of Aspire, the connection string will not include the `EntityPath` property, so the `EventHubName` property must be set in the settings callback for the preferred client. Future versions of Aspire will include the `EntityPath` property in the connection string and will not require the `EventHubName` property to be set in this scenario.

Expand Down
6 changes: 4 additions & 2 deletions src/Components/Aspire.Azure.Messaging.ServiceBus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ dotnet add package Aspire.Hosting.Azure.ServiceBus
Then, in the _Program.cs_ file of `AppHost`, add a Service Bus connection and consume the connection using the following methods:

```csharp
var serviceBus = builder.AddAzureServiceBus("sb");
var serviceBus = builder.ExecutionContext.IsPublishMode
? builder.AddAzureServiceBus("sb")
? builder.AddConnectionString("sb");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(serviceBus);
```

The `AddAzureServiceBus` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:sb` config key. The `WithReference` method passes that connection information into a connection string named `sb` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddAzureServiceBus` method adds an Azure Service Bus Namespace to the builder. Or `AddConnectionString` can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:sb` config key. The `WithReference` method passes that connection information into a connection string named `sb` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureServiceBusClient("sb");
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Aspire.Azure.Search.Documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ dotnet add package Aspire.Hosting.Azure.Search
Then, in the _Program.cs_ file of `AppHost`, add an Azure Search service and consume the connection using the following methods:

```csharp
var search = builder.AddAzureSearch("search");
var search = builder.ExecutionContext.IsPublishMode
? builder.AddAzureSearch("search")
: builder.AddConnectionString("search");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(search);
```

The `AddAzureSearch` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:search` config key. The `WithReference` method passes that connection information into a connection string named `search` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddAzureSearch` method adds an Azure AI Search resource to the builder. Or `AddConnectionString` can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:search` config key. The `WithReference` method passes that connection information into a connection string named `search` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureSearchClient("search");
Expand Down
8 changes: 6 additions & 2 deletions src/Components/Aspire.Azure.Security.KeyVault/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,17 @@ dotnet add package Aspire.Hosting.Azure.KeyVault
Then, in the _Program.cs_ file of `AppHost`, add a Key Vault connection and consume the connection using the following methods:

```csharp
var keyVault = builder.AddAzureKeyVault("secrets");
// Service registration
var keyVault = builder.ExecutionContext.IsPublishMode
? builder.AddAzureKeyVault("secrets")
: builder.AddConnectionString("secrets");

// Service consumption
var myService = builder.AddProject<Projects.MyService>()
.WithReference(keyVault);
```

The `AddAzureKeyVault` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:secrets` config key. The `WithReference` method passes that connection information into a connection string named `secrets` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddAzureKeyVault` method adds an Azure Key Vault resource to the builder. Or `AddConnectionString` can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:secrets` config key. The `WithReference` method passes that connection information into a connection string named `secrets` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureKeyVaultClient("secrets");
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Aspire.Azure.Storage.Blobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ dotnet add package Aspire.Hosting.Azure.Storage
Then, in the _Program.cs_ file of `AppHost`, add a Blob Storage connection and consume the connection using the following methods:

```csharp
var blobs = builder.AddAzureStorage("storage").AddBlobs("blobs");
var blobs = builder.ExecutionContext.IsPublishMode
? builder.AddAzureStorage("storage").AddBlobs("blobs")
? builder.AddConnectionString("blobs");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(blobs);
```

The `AddBlobs` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:blobs` config key. The `WithReference` method passes that connection information into a connection string named `blobs` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddBlobs` method adds an Azure Storage blob resource to the builder. Or `AddConnectionString` method can be used be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:blobs` config key. The `WithReference` method passes that connection information into a connection string named `blobs` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureBlobClient("blobs");
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Aspire.Azure.Storage.Queues/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ dotnet add package Aspire.Hosting.Azure.Storage
Then, in the _Program.cs_ file of `AppHost`, add a Storage Queue connection and consume the connection using the following methods:

```csharp
var queue = builder.AddAzureStorage("storage").AddQueues("queue");
var queue = builder.ExecutionContext.IsPublishMode
? builder.AddAzureStorage("storage").AddQueues("queue")
? builder.AddConnectionString("queue");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(queue);
```

The `AddQueues` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:queue` config key. The `WithReference` method passes that connection information into a connection string named `queue` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddQueues` method adds an Azure Storage queue to the builder. Or `AddConnectionString` can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:queue` config key. The `WithReference` method passes that connection information into a connection string named `queue` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureQueueClient("queue");
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Aspire.Microsoft.Azure.Cosmos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ dotnet add package Aspire.Hosting.Azure.CosmosDB
Then, in the _Program.cs_ file of `AppHost`, add a Cosmos DB connection and consume the connection using the following methods:

```csharp
var cosmosdb = builder.AddAzureCosmosDB("cdb").AddDatabase("cosmosdb");
var cosmosdb = builder.ExecutionContext.IsPublishMode
? builder.AddAzureCosmosDB("cdb").AddDatabase("cosmosdb")
: builder.AddConnectionString("cosmosdb");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(cosmosdb);
```

The `AddAzureCosmosDB` method will read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:cosmosdb` config key. The `WithReference` method passes that connection information into a connection string named `cosmosdb` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:
The `AddAzureCosmosDB` method will add an Azure Cosmos DB resource to the builder. Or `AddConnectionString` can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the `ConnectionStrings:cosmosdb` config key. The `WithReference` method passes that connection information into a connection string named `cosmosdb` in the `MyService` project. In the _Program.cs_ file of `MyService`, the connection can be consumed using:

```csharp
builder.AddAzureCosmosDBClient("cosmosdb");
Expand Down

0 comments on commit 45a54c5

Please sign in to comment.