2

I am trying to figure out the proper Azure sql db connection string to use, when using MSIs

I am now authenticating to sql via Managed Service Indentities (MSIs), and do not have "username and password"

The connection string type is ADO.NET

Prior to using MSI, my connection string was in the below format:

Server=tcp:sqlserver.azurenet,1433;Initial Catalog=testdb;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";

Am i simply removing the User ID={your_username};Password={your_password}??

Thank you

1 Answer 1

2

When connecting to Azure SQL using MSI, the connection authentication method is token. Therefore you cannot use a regular connection string you have indicated above. There is a C# example available in the MSI tutorial ( see below) https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-windows-vm-access-sql although I have not tried it on my own. Thanks, Mirek

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for the response.
Thank you for the response. That documentation isnt to helpful, as my MSI is for an Azure Function App, contacting Azure SQL database. I am trying to figure out how to write the connection string, to allow authentication for my function app MSI. we are using ADO.NET connection string type
I have successfully hardcoded the proper Sql db connection string in each of my function app "connection String" settings, using the following CLI code: az webapp config connection-string set --resource-group $core_rg --name $func_app9 --settings MyDbConnection='Server=tcp:sqlsrv1.database.azure.net.database.windows.net,1433;Database=testdb;' --connection-string-type SQLAzure My Question is: how to i write this out for a Keyvault Secret? Where does the "Type SQLAzure" go in this connection string?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.