Api Connection created using ARM Api over azapi Terraform provider has issues with authentication

MatsThieme-1461 0 Reputation points
2024-09-17T15:20:19.5733333+00:00

I deployed an API Connection resource using the azapi Terraform provider. The issue is that the username and password I sent to Azure seem to be ignored. The deployed resource shows an error that username and password are missing.

The "JSON view" of this resource looks like this:

{
    "kind": "V2",
    "properties": {
        "displayName": "<name>",
        "authenticatedUser": {},
        "overallStatus": "Error",
        "statuses": [
            {
                "status": "Error",
                "target": "username",
                "error": {
                    "code": "ConfigurationNeeded",
                    "message": "Parameter value missing."
                }
            },
            {
                "status": "Error",
                "target": "password",
                "error": {
                    "code": "ConfigurationNeeded",
                    "message": "Parameter value missing."
                }
            }
        ],
        "connectionState": "Enabled",
        "parameterValueSet": {
            "name": "sqlAuthentication",
            "values": {
                "database": {
                    "value": "<db>"
                },
                "gateway": {
                    "value": {
                        "name": "<>",
                        "id": "<>",
                        "type": "Microsoft.Web/connectionGateways"
                    }
                },
                "server": {
                    "value": "<>"
                }
            }
        },
        "customParameterValues": {},
        "createdTime": "2024-09-16T13:30:12.6106704Z",
        "changedTime": "2024-09-16T13:30:12.6106704Z",
        "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.1710/1.0.1710.3861/sql/icon.png",
            "brandColor": "#ba141a",
            "category": "Standard",
            "id": "<>",
            "type": "Microsoft.Web/locations/managedApis"
        },
        "testLinks": [
            {
                "requestUri": "<>",
                "method": "get"
            }
        ],
        "testRequests": [
            {
                "body": {
                    "request": {
                        "method": "get",
                        "path": "testconnection"
                    }
                },
                "requestUri": "<>",
                "method": "POST"
            }
        ],
        "connectionRuntimeUrl": "<>"
    },
    "id": "<>",
    "name": "<>",
    "type": "Microsoft.Web/connections",
    "location": "<>",
    "tags": {}
}

The body of the ARM request includes the username and password like this:

        "parameterValueSet": {
            "name": "sqlAuthentication",
            "values": {
                "database": {
                    "value": "<db>"
                },
                "gateway": {
                    "value": {
                        "name": "<>",
                        "id": "<>",
                        "type": "Microsoft.Web/connectionGateways"
                    }
                },
                "server": {
                    "value": "<>"
                },
                "username": {
                    "value": "<>"
                },
                "password": {
                    "value": "<>"
                }
            }
        },

Also unsuccessfully I tried using parameterValues instead of parameterValueSet.

The way I got this to work is by manually setting username and password in the Azure Portal after the initial deployment, but this is not a solution for me.

As this is poorly documented (ms learn) I hope to find answers here.

Has anyone else had this issue and figured out a solution?

Thank you in advance

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,131 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.