0
votes

I created a Xamarin Forms app that reads data from an Azure SQL database.

Currently i login into the SQL database with an username and an userpassword directly in the Sourcecode:

SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
                builder.DataSource = "tcp:nnnnnnnn.database.windows.net";
                builder.UserID = "userID";
                builder.Password = "userPassword";
                builder.InitialCatalog = "databaseName";

To do that, I currently have a resource group in Azure that contains a computer with SQL-Server and a SQL-Database.

Now I want to switch from the test phase to the production phase.

My idea: What I need is to give my app access to the databse without enter username or password or any other credentials.

For this problem, must I create also an app-service in azure or a virtuell computer? Is Azure-Active-Directory the right way? Must I create Managed Identitys?

What is the right workflow to do this?

Thanks in advance for your help

Oskar

2
Managed identity with a Key Vault can help you achieve this. An example, although in Java is provided in this answer. - Anoop R Desai

2 Answers

0
votes

I would definitely recommend creating a separate app (which can be an App Service) to serve as the data access layer, so that the mobile app does not have any potentially exploitable direct access to your database.

If the mobile app sends requests to an API app, the API can securely access the database with the help of a Managed Service Identity and a Key Vault containing the connection string, as Anoop referenced. Here is are documentation pages for Managed Service Identity and Key Vault references.

0
votes

Hi ChiefMcFrank and Anoop, Thank you for your answers. I will try to implement this and report on the result ...