Skip to content

Commit fbf7946

Browse files
Merge pull request #219321 from juliakm/users/jukullam/addyaml-cosmoscicd
Add YAML option to CosmosDB article
2 parents 61f0e8a + 425d079 commit fbf7946

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

articles/cosmos-db/tutorial-setup-ci-cd.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Set up CI/CD pipeline with Azure Cosmos DB Emulator build task
33
description: Tutorial on how to set up build and release workflow in Azure DevOps using the Azure Cosmos DB emulator build task
44
ms.service: cosmos-db
55
ms.topic: how-to
6-
ms.date: 01/28/2020
6+
ms.date: 11/22/2022
77
ms.author: esarroyo
88
author: StefArroyo
99
ms.reviewer: mjbrown
@@ -18,6 +18,9 @@ ms.custom: devx-track-csharp, ignite-2022
1818
The Azure Cosmos DB Emulator provides a local environment that emulates the Azure Cosmos DB service for development purposes. The emulator allows you to develop and test your application locally, without creating an Azure subscription or incurring any costs.
1919

2020
## PowerShell Task for Emulator
21+
22+
### [Classic](#tab/classic)
23+
2124
A typical PowerShell based task that will start the Azure Cosmos DB emulator can be scripted as follows:
2225

2326
Example of a job configuration, selecting the "windows-2019" agent type.
@@ -57,7 +60,56 @@ IPAddress = $IPAddress.IPAddress
5760
}
5861
```
5962

60-
For agents that do not come with the Azure Cosmos DB emulator preinstalled, you can instead download the latest emulator's MSI package from https://aka.ms/cosmosdb-emulator using 'curl' or 'wget', then leverage ['msiexec'](/windows-server/administration/windows-commands/msiexec) to 'quiet' install it. After the install, you can run a similar PowerShell script as the one above to start the emulator.
63+
You also have the option of building your own [self-hosted Windows agent](/azure/devops/pipelines/agents/v2-windows) if you need to use an agent that doesn't come with the Azure Cosmos DB emulator preinstalled. On your self-hosted agent, you can download the latest emulator's MSI package from https://aka.ms/cosmosdb-emulator using 'curl' or 'wget', then use ['msiexec'](/windows-server/administration/windows-commands/msiexec) to 'quiet' install it. After the install, you can run a similar PowerShell script as the one above to start the emulator.
64+
65+
### [YAML](#tab/yaml)
66+
67+
68+
You can use the `windows-2019` agent and a PowerShell script task to run the Azure Cosmos DB Emulator.
69+
70+
```yaml
71+
trigger:
72+
- main
73+
74+
pool:
75+
vmImage: windows-2019
76+
77+
steps:
78+
- task: PowerShell@2
79+
inputs:
80+
targetType: 'inline'
81+
script: |
82+
# Write your PowerShell commands here.
83+
84+
dir "C:\Program Files\Azure Cosmos DB Emulator\"
85+
86+
Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
87+
88+
$startEmulatorCmd = "Start-CosmosDbEmulator -NoFirewall -NoUI"
89+
Write-Host $startEmulatorCmd
90+
Invoke-Expression -Command $startEmulatorCmd
91+
92+
# Pipe an emulator info object to the output stream
93+
94+
$Emulator = Get-Item "$env:ProgramFiles\Azure Cosmos DB Emulator\Microsoft.Azure.Cosmos.Emulator.exe"
95+
$IPAddress = Get-NetIPAddress -AddressFamily IPV4 -AddressState Preferred -PrefixOrigin Manual | Select-Object IPAddress
96+
97+
New-Object PSObject @{
98+
Emulator = $Emulator.BaseName
99+
Version = $Emulator.VersionInfo.ProductVersion
100+
Endpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "https://${_}:8081/" }
101+
MongoDBEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "mongodb://${_}:10255/" }
102+
CassandraEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "tcp://${_}:10350/" }
103+
GremlinEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "http://${_}:8901/" }
104+
TableEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "https://${_}:8902/" }
105+
IPAddress = $IPAddress.IPAddress
106+
}
107+
```
108+
109+
110+
You also have the option of building your own [self-hosted Windows agent](/azure/devops/pipelines/agents/v2-windows) if you need to use an agent that doesn't come with the Azure Cosmos DB emulator preinstalled. On your self-hosted agent, you can download the latest emulator's MSI package from https://aka.ms/cosmosdb-emulator using 'curl' or 'wget', then use ['msiexec'](/windows-server/administration/windows-commands/msiexec) to 'quiet' install it. After the install, you can run a similar PowerShell script as the one above to start the emulator.
111+
112+
---
61113
62114
## Next steps
63115

0 commit comments

Comments
 (0)