Skip to content

Commit 15f6d56

Browse files
committed
add staging yml file
1 parent 78ccb56 commit 15f6d56

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

sdk/cosmos/cosmos-staging.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Variable 'ACCOUNT_HOST' was defined in the Variables tab
2+
# Variable 'ACCOUNT_KEY' was defined in the Variables tab
3+
# Variable 'cosmosdb.azurecr.io.Password' was defined in the Variables tab
4+
# Variable 'cosmosdb.azurecr.io.Username' was defined in the Variables tab
5+
# Variable 'AZURE_COSMOS_ENABLE_CIRCUIT_BREAKER' was defined in the Variables tab
6+
# Agent Queue 'Azure Pipelines' was used with unrecognized Agent Specification, vmImage property must be specified to determine image - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software
7+
name: $(date:yyyyMMdd)$(rev:.r)
8+
resources:
9+
repositories:
10+
- repository: self
11+
type: git
12+
ref: refs/heads/main
13+
jobs:
14+
- job: Job_1
15+
displayName: Python 3
16+
timeoutInMinutes: 240
17+
pool:
18+
name: Azure Pipelines
19+
steps:
20+
- checkout: self
21+
submodules: recursive
22+
fetchDepth: 5
23+
fetchTags: true
24+
- task: UsePythonVersion@0
25+
name: ''
26+
displayName: Use Python 3.x
27+
condition: succeededOrFailed()
28+
- task: Bash@3
29+
displayName: Bash Script
30+
inputs:
31+
targetType: inline
32+
script: >-
33+
cd ./sdk/cosmos/azure-cosmos
34+
35+
pip install tox==4.5.0
36+
37+
tox -c ../../../eng/tox/tox.ini --root . -e whl -- -k 'not cosmosEmulator and not cosmosMultiRegion and not cosmosCircuitBreaker and not cosmosCircuitBreakerMultiRegion'
38+
- task: AzurePowerShell@5
39+
displayName: Clean up resources
40+
condition: always()
41+
inputs:
42+
ConnectedServiceNameARM: d71e80c4-c3df-4a27-9fc7-f25563bbb0d1
43+
ScriptType: InlineScript
44+
Inline: "$uri = New-Object System.Uri(\"$(ACCOUNT_HOST)\")\n\n$accountName = $uri.Host.Split('.')[0]\nWrite-Host \"Clean up databases from $accountName\"\n\n$res = Get-AzResource -Name $accountName -ResourceType \"Microsoft.DocumentDb/databaseAccounts\"\n\nif ($res -ne $null) {\n\n $account = Get-AzCosmosDBAccount -ResourceId $res.ResourceId\n\n $dbs = Get-AzCosmosDBSqlDatabase -ParentObject $account\n\n $dbs | Write-Output\n\n $dbs | Remove-AzCosmosDBSqlDatabase\n \n Write-Host \"$accountName is cleaned\"\n}\nelse {\n Write-Host \"Unable to find $accountName\"\n}"
45+
errorActionPreference: continue
46+
TargetAzurePs: LatestVersion
47+
- task: Bash@3
48+
displayName: Additional clean up using Python SDK - install SDK
49+
condition: succeededOrFailed()
50+
inputs:
51+
targetType: inline
52+
script: pip install azure-cosmos
53+
- task: PythonScript@0
54+
displayName: Additional clean up using Python SDK
55+
condition: succeededOrFailed()
56+
inputs:
57+
scriptSource: inline
58+
script: >-
59+
# python tests creates databases with special characters (!@$%^&*()-~`'_[]{}|;:,.<>) and PS and Portal unable to remove them. This task additionally clean resource that couldn't be removed using previous PS task
60+
61+
62+
import os
63+
64+
import azure.cosmos.cosmos_client as cosmos_client
65+
66+
67+
client = cosmos_client.CosmosClient("$(ACCOUNT_HOST)", "$(ACCOUNT_KEY)")
68+
69+
70+
for db in client.list_databases():
71+
72+
client.delete_database(db["id"])
73+
...

0 commit comments

Comments
 (0)