Oliver Nilsen
Oliver Nilsen

Reputation: 1273

API Connection - username and password in ARM template

I want to provide username and password in the ARM template, such that it gets deployed and populated in Azure and can be seen under "Edit API Connection" in the Azure Portal.

enter image description here

Here is part of the ARM template:

"resources": [
    {
      "type": "Microsoft.Web/connections",
      "apiVersion": "2016-06-01",
      "name": "[parameters('connections_sql_name')]",
      "location": "westeurope",
      "properties": {
        "displayName": "Test Connection Name",
        "parameterValues": {
          "server": "[parameters('sql_server')]",
          "database": "[parameters('sql_database')]",
          "authType": "[parameters('sql_authType')]",
          "userName": "[parameters('username')",
          "password": "[parameters('password')]"
        },
        "customParameterValues": {},
        "api": {
          "id": "[concat('/subscriptions/', subscription().subscriptionID, '/providers/Microsoft.Web/locations/westeurope/managedApis/sql')]"
        }
      }
    }

Server, Database and AuthType gets populated, but I cannot get the userName and password parameters to get populated in the deployment.

Upvotes: 0

Views: 2776

Answers (1)

Stringfellow
Stringfellow

Reputation: 2908

The 'Edit API connection' page will not show the Username nor the Password because they are of type securestring.

Reference: https://learn.microsoft.com/en-us/connectors/sql/#creating-a-connection enter image description here

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "connections_sql_name": {
      "type": "string",
      "defaultValue": "connections_sql_name"
    },
    "sql_server": {
      "type": "string",
      "defaultValue": "server201-dev-sql.database.windows.net"
    },
    "sql_database": {
      "type": "string",
      "defaultValue": "Incidents"
    },
    "sql_authType": {
      "type": "string",
      "defaultValue": "Windows"
    },
    "username": {
      "type": "securestring",
    },
    "password": {
      "type": "securestring"
    }
  },
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.Web/connections",
      "apiVersion": "2016-06-01",
      "name": "[parameters('connections_sql_name')]",
      "location": "westeurope",
      "properties": {
        "displayName": "Test Connection Name",
        "parameterValues": {
          "server": "[parameters('sql_server')]",
          "database": "[parameters('sql_database')]",
          "authType": "[parameters('sql_authType')]",
          "userName": "[parameters('username')]",
          "password": "[parameters('password')]"
        },
        "customParameterValues": {},
        "api": {
          "id": "[concat('/subscriptions/', subscription().subscriptionID, '/providers/Microsoft.Web/locations/westeurope/managedApis/sql')]"
        }
      }
    }
  ]
}

Upvotes: 2

Related Questions