Skip to content

Commit 3ecc043

Browse files
committed
Add docs for CosmosDB preview emulator
Fix #2376
1 parent c31d324 commit 3ecc043

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

docs/database/includes/cosmos-app-host.md

+24
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,27 @@ var cosmos = builder.AddAzureCosmosDB("cosmos-db").RunAsEmulator(
231231
```
232232

233233
The preceding code configures the Cosmos DB emulator container to have a partition count of `100`. This is a shorthand for setting the `AZURE_COSMOS_EMULATOR_PARTITION_COUNT` environment variable.
234+
235+
#### Use Linux-based emulator (preview)
236+
237+
The [next generation of the Azure Cosmos DB emulator](/azure/cosmos-db/emulator-linux) is entirely Linux-based and is available as a Docker container. It supports running on a wide variety of processors and operating systems.
238+
239+
To use the preview version of the Cosmos DB emulator, call the <xref:Aspire.Hosting.AzureCosmosExtensions.RunAsPreviewEmulator*> method. Since this feature is in preview, you need to explicitly opt into the preview feature by suppressing the `ASPIRECOSMOSDB001` experimental diagnostic.
240+
241+
The preview emulator also supports exposing a "Data Explorer" endpoint which allows you to view the data stored in the Cosmos DB emulator via a web UI. To enable the Data Explorer, call the <xref:Aspire.Hosting.AzureCosmosExtensions.WithDataExplorer*> method.
242+
243+
```csharp
244+
#pragma warning disable ASPIRECOSMOSDB001
245+
246+
var builder = DistributedApplication.CreateBuilder(args);
247+
248+
var cosmos = builder.AddAzureCosmosDB("cosmos-db").RunAsPreviewEmulator(
249+
emulator =>
250+
{
251+
emulator.WithDataExplorer();
252+
});
253+
254+
// After adding all resources, run the app...
255+
```
256+
257+
The preceding code configures the Linux-based preview Cosmos DB emulator container, with the Data Explorer endpoint, to use at run time.

docs/diagnostics/overview.md

+22
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,25 @@ Alternatively, you can suppress this diagnostic with preprocessor directive by a
7474
// API that is causing the warning.
7575
#pragma warning restore ASPIREHOSTINGPYTHON001
7676
```
77+
78+
## ASPIRECOSMOSDB001
79+
80+
<span id="ASPIRECOSMOSDB001"></span>
81+
82+
.NET Aspire provides a way to use the CosmosDB Linux-based (preview) emulator. Since this emulator is in preview and the shape of this API is expected to change in the future, it has been marked as _Experimental_. To suppress the compiler error/warning use the following code:
83+
84+
To suppress this diagnostic with the `SuppressMessageAttribute`, add the following code to your project file:
85+
86+
```xml
87+
<PropertyGroup>
88+
<NoWarn>$(NoWarn);ASPIRECOSMOSDB001</NoWarn>
89+
<PropertyGroup>
90+
```
91+
92+
Alternatively, you can suppress this diagnostic with preprocessor directive by adding the following code to your project:
93+
94+
```csharp
95+
#pragma warning disable ASPIRECOSMOSDB001
96+
// API that is causing the warning.
97+
#pragma warning restore ASPIRECOSMOSDB001
98+
```

0 commit comments

Comments
 (0)