I have a project of Net Core which it create database, tables and measures in a Tabular model.
I would like to create a data source to Azure SQL Server Database (I can do it whit sql server on premise).
My problem is in the connection string to azure.
I have seen in the Microsoft documentation that I need a ProviderDataSource to connect to a sql server on premise.
The following example is working, but I can't do it with Azure SQL Database.
I couldn't find an example
ProviderDataSource ProviderDS = new ProviderDataSource()
{
Name = datasourceName,
Description = "A data source definition that uses explicit Windows credentials for authentication against SQL Server ....",
ConnectionString = "Provider=MSOLEDBSQL; Data Source=" + ServerNameSQL + ";Initial Catalog=" + DataBaseNameSQL + ";Integrated Security=SSPI;Persist Security Info=false",
ImpersonationMode = ImpersonationMode.ImpersonateAccount,
Account = @"Domain/user",
Password = "mypassword",
};
After, I use it in my model
database.Model.DataSources.Add(ProviderDS);
I would like to see two examples and their best practices:
- How to create a data sources for my model using Azure AD?
- How to create a data sources for my model using DB User and password ?
To create database in Azure SQL server you can use "Microsoft.Data.SqlClient" Library. I tried with below code to create database by using user name and password:
It executed successfully.
And database is created successfully in my Azure SQL server.