Reputation: 366
I am using Terraform to create the infrastructure layer of the solution on Azure.
The below code creates a SQL Connection in Azure however its V1 I want V2 and set ‘Authentication = ManagedIdentity’- how to modify the below?
# Create Azure API Connection SQL Connection. This is used by the Logic-App to query the Azure SQL databases.
resource "azapi_resource" "sql_conn" {
type = "Microsoft.Web/connections@2016-06-01"
name = local.sql_connection
parent_id = data.azurerm_resource_group.solution_rg.id
location = var.location
tags = local.tags
body = jsonencode({
properties = {
displayName = "${local.sql_connection}"
statuses = [
{
"status" : "Connected"
}
]
parameterValues = {
name = "managedIdentityAuth"
#values = {}
}
api = {
name = "sql"
displayName = "SQL Server"
description = "Microsoft SQL Server is a relational database management system developed by Microsoft. Connect to SQL Server to manage data. You can perform various actions such as create, update, get, and delete on rows in a table."
iconUri = "https://connectoricons-prod.azureedge.net/releases/v1.0.1686/1.0.1686.3706/sql/icon.png"
brandColor = "#ba141a"
id = "/subscriptions/${data.azurerm_subscription.current.subscription_id}/providers/Microsoft.Web/locations/uksouth/managedApis/sql"
type = "Microsoft.Web/locations/managedApis"
}
}
})
}
Authenatication Required...
Upvotes: 0
Views: 110
Reputation: 366
This worked - v2 and managed indentity...sensitive values modified...
resource "azurerm_resource_group_template_deployment" "api_sql_connection2" {
name = "${local.sql_api_connection}-3"
resource_group_name = local.solution_rg
tags = local.tags
deployment_mode = "Incremental" # DO NOT CHANGE OTHERWISE YOU CAN ACCIDENTLY DELETE AZ RESOURCES
template_content = <<TEMPLATE
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [{
"apiVersion": "2016-06-01",
"kind": "V2",
"properties": {
"displayName": "api_sql_connection",
"authenticatedUser": {},
"overallStatus": "Ready",
"statuses": [
{
"status": "Ready"
}
],
"connectionState": "Enabled",
"parameterValueSet": {
"name": "oauthMI",
"values": {}
},
"customParameterValues": {},
"createdTime": "2024-07-01T08:11:41.176Z",
"changedTime": "2024-07-03T07:36:09.333Z",
"api": {
"name": "sql",
"displayName": "SQL Server",
"description": "Microsoft SQL Server is a relational database management system developed by Microsoft. Connect to SQL Server to manage data. You can perform various actions such as create, update, get, and delete on rows in a table.",
"iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1686/1.0.1686.3706/sql/icon.png",
"brandColor": "#ba141a",
"category": "Standard",
"id": "/subscriptions/XXX/providers/Microsoft.Web/locations/uksouth/managedApis/sql",
"type": "Microsoft.Web/locations/managedApis"
},
"testLinks": [
{
"requestUri": "https://management.azure.com:443/subscriptions/XXX/resourceGroups/abc/providers/Microsoft.Web/connections/sql/extensions/proxy/testconnection?api-version=2018-07-01-preview",
"method": "get"
}
],
"testRequests": [
{
"body": {
"request": {
"method": "get",
"path": "testconnection"
}
},
"inputParameters": [
{
"path": "body.properties.workflowReference.id",
"type": "string",
"description": "The workflow reference resource id."
}
],
"requestUri": "https://management.azure.com:443/subscriptions/XXX/resourceGroups/abc/providers/Microsoft.Web/connections/sql/dynamicInvoke?api-version=2018-07-01-preview",
"method": "POST"
}
],
"connectionRuntimeUrl": "https://38d4602d576749ad.06.common.logic-uksouth.azure-apihub.net/apim/sql/909f2a0112b3473abca8ab59120da340"
},
"id": "/subscriptions/XXX/resourceGroups/abc/providers/Microsoft.Web/connections/sql",
"name": "sql",
"type": "Microsoft.Web/connections",
"location": "uksouth"
}]
}
TEMPLATE
}
Upvotes: 0