Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adventures with Azure ARM Templates: Create Logic App API Connection for Cosmos
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connectionName": {
"type": "String"
},
"cosmosAccountName": {
"type": "String"
}
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"name": "[parameters('connectionName')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/documentdb')]"
},
"displayName": "[parameters('cosmosAccountName')]",
"parameterValues": {
"databaseAccount": "[parameters('cosmosAccountName')]",
"accessKey": "[listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosAccountName')), '2015-04-08').primaryMasterKey]"
}
}
}
]
}
Param(
[String] [Parameter(Mandatory = $true)] $ResourceGroupName,
[String] $ConnectionName = '',
[String] [Parameter(Mandatory = $true)] $CosmosAccountName,
[String] $TemplateFile = "LogicAppCosmosConnection.json"
)
$ErrorActionPreference = "Stop"
$TemplateFile = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $TemplateFile))
if ($null -eq $ConnectionName -or $ConnectionName.Trim() -eq '') {
$ConnectionName = $CosmosAccountName + "-cn"
}
New-AzResourceGroupDeployment `
-Name ((Get-ChildItem $TemplateFile).BaseName + "-" + ((Get-Date).ToUniversalTime()).ToString("MMdd-HHmm")) `
-ResourceGroupName $ResourceGroupName `
-TemplateFile $TemplateFile `
-Force `
-Verbose `
-connectionName $ConnectionName `
-cosmosAccountName $CosmosAccountName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.