I have an ARM template that (among others) creates a database on an Azure SQL server (which is also created by the template).
I need to output the database ADO.NET connectionstring.
Becuase I wasn't sure what the key is called, I am outputting the whole object: This is what I have on the JSON template file:
"DatabaseConnectionString": {
"type": "object",
"value": "[listkeys(variables('dbResourceId'), variables('apiVersion'))]"
}
The dbResourceId
is 100% correct. If I output it instead, I get the correct ID and the apiVersion
is the same I use when creating the DB.
BUT, I get this error:
"code": "NotFound",
"message": "Resource not found for the segment 'listkeys'.",
The database is being created correctly
I have the exact same pattern/idea with a service bus and it works perfectly Help, this is killing me
Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.
Get ADO.NET connection information (optional - SQL Database only) Navigate to the database blade in the Azure portal and, under Settings, select Connection strings. Review the complete ADO.NET connection string. Copy the ADO.NET connection string if you intend to use it.
Well, looks like the connection string is simply not a property, this is why it cannot be returned with listkeys, it needs to be "calculated" using concat
"DatabaseConnectionString": {
"type": "string",
"value": "[concat('Server=tcp:',reference(variables('sqlserverName')).fullyQualifiedDomainName,',1433;Initial Catalog=',variables('dbName'),';Persist Security Info=False;User ID=',reference(variables('sqlserverName')).administratorLogin,';Password=',reference(variables('sqlserverName')).administratorLoginPassword,';MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;')]"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With