-
-
Save mattruma/b5a94db43cdf3641597e7d92c8f28275 to your computer and use it in GitHub Desktop.
Adventures with Azure ARM Templates: Create Logic App API Connection for Cosmos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$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]" | |
} | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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