Skip to content

Commit 8068717

Browse files
committed
Updating code snippet format
1 parent 0a5b469 commit 8068717

7 files changed

+23
-21
lines changed

articles/cosmos-db/manage-gremlin-with-resource-manager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Create Azure Cosmos DB resources using an Azure Resource Manager template. This
2020
> Account names must be lowercase and 44 or fewer characters.
2121
> To update RU/s, resubmit the template with updated throughput property values.
2222
23-
[!code-json[create-cosmos-gremlin](~/quickstart-templates/101-cosmosdb-gremlin/azuredeploy.json)]
23+
:::code language="json" source="~/quickstart-templates/101-cosmosdb-gremlin/azuredeploy.json":::
2424

2525
## Deploy with the Azure CLI
2626

articles/cosmos-db/manage-mongodb-with-resource-manager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Create Azure Cosmos DB resources using an Azure Resource Manager template. This
2222
>
2323
> Currently you can only create 3.2 version (that is, accounts using the endpoint in the format `*.documents.azure.com`) of Azure Cosmos DB's API for MongoDB accounts by using PowerShell, CLI, and Resource Manager templates. To create 3.6 version of accounts, use Azure portal instead.
2424
25-
[!code-json[create-cosmos-mongo](~/quickstart-templates/101-cosmosdb-mongodb/azuredeploy.json)]
25+
:::code language="json" source="~/quickstart-templates/101-cosmosdb-mongodb/azuredeploy.json":::
2626

2727
### Deploy via the Azure CLI
2828

articles/cosmos-db/manage-sql-with-resource-manager.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ To create the Azure Cosmos DB resources, copy the following example template and
3535
> * Account names are limited to 44 characters, all lowercase.
3636
> * To change the throughput values, resubmit the template with updated RU/s.
3737
38-
[!code-json[create-cosmosdb-sql](~/quickstart-templates/101-cosmosdb-sql/azuredeploy.json)]
38+
:::code language="json" source="~/quickstart-templates/101-cosmosdb-sql/azuredeploy.json":::
3939

4040
> [!NOTE]
4141
> To create a container with large partition key, modify the previous template to include the `"version":2` property within the `partitionKey` object.
@@ -132,7 +132,7 @@ Copy the following example template and deploy it as described, either with [Pow
132132
* Optionally, you can visit [Azure Quickstart Gallery](https://azure.microsoft.com/resources/templates/101-cosmosdb-sql-container-sprocs/) and deploy the template from the Azure portal.
133133
* You can also download the template to your local computer or create a new template and specify the local path with the `--template-file` parameter.
134134

135-
[!code-json[create-cosmosdb-sql-sprocs](~/quickstart-templates/101-cosmosdb-sql-container-sprocs/azuredeploy.json)]
135+
:::code language="json" source="~/quickstart-templates/101-cosmosdb-sql-container-sprocs/azuredeploy.json":::
136136

137137
### Deploy with PowerShell
138138

articles/cosmos-db/manage-table-with-resource-manager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Create Azure Cosmos DB resources using an Azure Resource Manager template. This
2020
> Account names must be lowercase and 44 or fewer characters.
2121
> To update RU/s, resubmit the template with updated throughput property values.
2222
23-
[!code-json[create-cosmos-table](~/quickstart-templates/101-cosmosdb-table/azuredeploy.json)]
23+
:::code language="json" source="~/quickstart-templates/101-cosmosdb-table/azuredeploy.json":::
2424

2525
### Deploy via PowerShell
2626

articles/cosmos-db/quick-create-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ An Azure subscription or free Azure Cosmos DB trial account
3131

3232
The template used in this quickstart is from [Azure Quickstart templates](https://azure.microsoft.com/resources/templates/101-cosmosdb-create/).
3333

34-
[!code-json[<Resource Manager template create Azure Cosmos DB>](~/quickstart-templates/101-cosmosdb-create/azuredeploy.json)]
34+
:::code language="json" source="~/quickstart-templates/101-cosmosdb-create/azuredeploy.json":::
3535

3636
Three Azure resources are defined in the template:
3737

articles/cosmos-db/sql-api-dotnet-application.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Now let's add the models, the views, and the controllers to this MVC application
105105

106106
1. Replace the contents of *Item.cs* class with the following code:
107107

108-
[!code-csharp[Main](~/samples-cosmosdb-dotnet-core-web-app/src/Models/Item.cs)]
108+
:::code language="csharp" source="~/samples-cosmosdb-dotnet-core-web-app/src/Models/Item.cs":::
109109

110110
Azure Cosmos DB uses JSON to move and store data. You can use the `JsonProperty` attribute to control how JSON serializes and deserializes objects. The `Item` class demonstrates the `JsonProperty` attribute. This code controls the format of the property name that goes into JSON. It also renames the .NET property `Completed`.
111111

@@ -178,7 +178,7 @@ Once you complete these steps, close all the *cshtml* documents in Visual Studio
178178

179179
1. Replace the contents of *ItemController.cs* with the following code:
180180

181-
[!code-csharp[Main](~/samples-cosmosdb-dotnet-core-web-app/src/Controllers/ItemController.cs)]
181+
:::code language="csharp" source="~/samples-cosmosdb-dotnet-core-web-app/src/Controllers/ItemController.cs":::
182182

183183
The **ValidateAntiForgeryToken** attribute is used here to help protect this application against cross-site request forgery attacks. Your views should work with this anti-forgery token as well. For more information and examples, see [Preventing Cross-Site Request Forgery (CSRF) Attacks in ASP.NET MVC Application][Preventing Cross-Site Request Forgery]. The source code provided on [GitHub][GitHub] has the full implementation in place.
184184

@@ -198,11 +198,11 @@ First, we'll add a class that contains the logic to connect to and use Azure Cos
198198

199199
1. Replace the contents of *CosmosDBService.cs* with the following code:
200200

201-
[!code-csharp[Main](~/samples-cosmosdb-dotnet-core-web-app/src/Services/CosmosDbService.cs)]
201+
:::code language="csharp" source="~/samples-cosmosdb-dotnet-core-web-app/src/Services/CosmosDbService.cs":::
202202

203203
1. Repeat the previous two steps, but this time, use the name *ICosmosDBService*, and use the following code:
204204

205-
[!code-csharp[Main](~/samples-cosmosdb-dotnet-core-web-app/src/Services/ICosmosDbService.cs)]
205+
:::code language="csharp" source="~/samples-cosmosdb-dotnet-core-web-app/src/Services/ICosmosDbService.cs":::
206206

207207
1. In the **ConfigureServices** handler, add the following line:
208208

@@ -214,7 +214,7 @@ First, we'll add a class that contains the logic to connect to and use Azure Cos
214214

215215
1. Within the same file, add the following method **InitializeCosmosClientInstanceAsync**, which reads the configuration and initializes the client.
216216

217-
[!code-csharp[](~/samples-cosmosdb-dotnet-core-web-app/src/Startup.cs?name=InitializeCosmosClientInstanceAsync)]
217+
:::code language="csharp" source="~/samples-cosmosdb-dotnet-core-web-app/src/Startup.cs" id="InitializeCosmosClientInstanceAsync":::
218218

219219
1. Define the configuration in the project's *appsettings.json* file. Open the file and add a section called **CosmosDb**:
220220

articles/cosmos-db/sql-api-get-started.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Great! Now that we finished the setup, let's start writing some code. For the co
141141

142142
1. Add the following code to run the **GetStartedDemoAsync** asynchronous task from your **Main** method. The **Main** method catches exceptions and writes them to the console.
143143

144-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=Main)]
144+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="Main":::
145145

146146
1. Select F5 to run your application.
147147

@@ -155,7 +155,7 @@ A database is the logical container of items partitioned across containers. Eith
155155
156156
1. Copy and paste the `CreateDatabaseAsync` method below your `GetStartedDemoAsync` method.
157157

158-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=CreateDatabaseAsync&highlight=7)]
158+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="CreateDatabaseAsync":::
159159

160160
`CreateDatabaseAsync` creates a new database with ID `FamilyDatabase` if it doesn't already exist, that has the ID specified from the `databaseId` field.
161161

@@ -276,7 +276,7 @@ A container can be created by using either the [**CreateContainerIfNotExistsAsyn
276276

277277
1. Copy and paste the `CreateContainerAsync` method below your `CreateDatabaseAsync` method. `CreateContainerAsync` creates a new container with the ID `FamilyContainer` if it doesn't already exist, by using the ID specified from the `containerId` field partitioned by `LastName` property.
278278

279-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=CreateContainerAsync&highlight=9)]
279+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="CreateContainerAsync&highlight":::
280280

281281
1. Copy and paste the code below where you instantiated the CosmosClient to call the **CreateContainer** method you just added.
282282

@@ -308,11 +308,13 @@ First, let's create a `Family` class that represents objects stored within Azure
308308

309309
1. Copy and paste the `Family`, `Parent`, `Child`, `Pet`, and `Address` class into `Family.cs`.
310310

311-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Family.cs)]
311+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Family.cs":::
312+
312313

313314
1. Back in *Program.cs*, add the `AddItemsToContainerAsync` method after your `CreateContainerAsync` method.
314315

315-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=AddItemsToContainerAsync)]
316+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="AddItemsToContainerAsync":::
317+
316318

317319
The code checks to make sure an item with the same ID doesn't already exist. We'll insert two items, one each for the *Andersen Family* and the *Wakefield Family*.
318320

@@ -341,7 +343,7 @@ Azure Cosmos DB supports rich queries against JSON documents stored in each cont
341343

342344
1. Copy and paste the `QueryItemsAsync` method after your `AddItemsToContainerAsync` method.
343345

344-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=QueryItemsAsync&highlight=10-11,17-18)]
346+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="QueryItemsAsync":::
345347

346348
1. Add a call to ``QueryItemsAsync`` in the ``GetStartedDemoAsync`` method.
347349

@@ -369,7 +371,7 @@ Now, we'll update an item in Azure Cosmos DB. We'll change the `IsRegistered` pr
369371

370372
1. Copy and paste the `ReplaceFamilyItemAsync` method after your `QueryItemsAsync` method.
371373

372-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=ReplaceFamilyItemAsync&highlight=15)]
374+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="ReplaceFamilyItemAsync":::
373375

374376
1. Add a call to `ReplaceFamilyItemAsync` in the `GetStartedDemoAsync` method.
375377

@@ -398,7 +400,7 @@ Now, we'll delete an item in Azure Cosmos DB.
398400

399401
1. Copy and paste the `DeleteFamilyItemAsync` method after your `ReplaceFamilyItemAsync` method.
400402

401-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=DeleteFamilyItemAsync&highlight=10)]
403+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="DeleteFamilyItemAsync":::
402404

403405
1. Add a call to `DeleteFamilyItemAsync` in the `GetStartedDemoAsync` method.
404406

@@ -428,11 +430,11 @@ Now we'll delete our database. Deleting the created database removes the databas
428430

429431
1. Copy and paste the `DeleteDatabaseAndCleanupAsync` method after your `DeleteFamilyItemAsync` method.
430432

431-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=DeleteDatabaseAndCleanupAsync)]
433+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="DeleteDatabaseAndCleanupAsync":::
432434

433435
1. Add a call to ``DeleteDatabaseAndCleanupAsync`` in the ``GetStartedDemoAsync`` method.
434436

435-
[!code-csharp[](~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs?name=GetStartedDemoAsync&highlight=14)]
437+
:::code language="csharp" source="~/cosmos-dotnet-getting-started/CosmosGettingStartedTutorial/Program.cs" id="GetStartedDemoAsync":::
436438

437439
1. Select F5 to run your application.
438440

0 commit comments

Comments
 (0)