UPDATE
You can follow the offical document to set in portal. I have try it and sucessed.
- Create SQL managed instances (maybe cost long time)
- Configure Active Directory admin
- Configure your db
When u have finished it, you can find connection string like pic. You just copy and paste it in your code. It works for me.
Connection strings like below
Server=tcp:panshubeidb.database.windows.net,1433;Initial Catalog=dbname;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication='Active Directory Password';
PRIVIOUS
Your SQL Connectionstrings should be like Server=tcp:testdb.database.windows.net,1433;Initial Catalog=test;Persist Security Info=False;User ID=sasasa;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
.
You can find it in portal like pic.
You also can configure your connectionstring's name in web.config.
<connectionStrings>
<add name="DefaultConnection" connectionString="You local db connnection strings or others" />
<add name="DefaultConnection11" connectionString="Data Source =**;Initial Catalog = {your db in server not azure};User Id = {userid};Password ={password};" />
</connectionStrings>
You can configure your Connectionstrings like the code I given. And when you want to depoly your apps. You can switch to your production database, and don't need change anything in your code. Fore more details, you can see this article .
Its priority is higher than the configuration in web.config, and it will cover the address in the code, so after setting it here, you do not need to modify your web.config
file when deploying.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…