Azure error - connection string difficulties - azure

I am working with an mvc5 application in vs 2015.
I am getting errors whenever I attempt to access items from the database
Login failed for user '{your_username}'.
When I go azure portal "allow access to azure services" setting is on with my client Ip address listed.
I think my connection string is not configured correctly. I can't figure out how to correctly configure it on my local machine and with azure.
I have kept my the connection string in my web config to my local server which worked previously:
In my web.config
<add name="IdentityDbContext" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=C:\Users\UserName\EduSmart_db.Mdf; Initial Catalog=EduSmart_db;Integrated Security=True" providerName="System.Data.SqlClient" />
In Azure Portal connection string
Server=tcp:xxxx.database.windows.net,1433;Initial Catalog=Edu;Persist Security Info=False;User ID=Name;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
How can I tell which connection string azure is using?
Is there a different problem i have not considered?

How can I tell which connection string azure is using?
Azure use the second connection string. The first one(localdb) just used in your local machine. The server can not get it. You could add Azure Sql connection string name in Context class to specific it.
Is there a different problem i have not considered?
You could check from these ways:
1.The firewall settings in Azure Sql Database. Yo could define a
range of ip address(like ×.×.×.0 to ×.×.×.255) instead of only one ip
address.
2.You could check Azure sql connection string in web.configs file like
this. It works fine on my side.
<connectionStrings>
<add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=tcp:[databasename].database.windows.net,1433;Initial Catalog=[databasename];Integrated Security=False;User Id=[username];Password=[password];Encrypt=True;TrustServerCertificate=False;MultipleActiveResultSets=True" />
</connectionStrings>
If you use Code First for Azure Sql, you could add related connection string name in Context class:
public ApplicationDbContext(): base("ConnectionStringName")
{
}
3.You could click Tools>Connect to Database>Microsoft SQL
Server>enter your server name, username and password about Azure
Sql. Then click Test Connection button to check whether you could connect successfully.
Besides, you could refer this article to learn how to access Azure Sql in your project locally.

You just need to publish your Web app and database to Azure as explained here.
To publish your web app, right-click the project and select Publish. On the create a site page provide existing SQL Azure server, database and login credentials.
Two database connections will be provided when you publish, one of them is the DBContext. When you publish the Web site with the Wizard data tables are not published.
Since you have configured firewall settings on SQL Azure, to publish the database go to the database project. Right-click the project and select Publish. On the Publish Database dialog, click on Edit and update information regarding the database on Azure. Save the profile and publish the database.

Related

How to open Azure database .bacpac locally for local Umbraco website?

I exported and downloaded my database from Azure as a .bacpac file.
I want to install Umbraco locally and use this database locally.
How do I do it?
Every time when I open the Microsoft SQL Server Management Studio it tries to connect to the database on Azure:
Then when I put the password it will connect to the database on Azure:
But I want to work on the local .bacpac file.
My questions are:
How do I connect on the Microsoft SQL Server Management Studio to the local .bacpac file ?
How do I connect in the Web.config to the local database ? What should I put in the connectionString?
<connectionStrings>
<remove name="umbracoDbDSN" />
<add name="umbracoDbDSN" connectionString="Server=tcp:xxxxx.database.windows.net,1433;Data Source=xxxxx.database.windows.net;Initial Catalog=xxxx;Persist Security Info=False;User ID=xxxx;Password=xxxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=3600;" providerName="System.Data.SqlClient" />
</connectionStrings>
So basically I want to open and work on the local .bacpac and not on the one on the server, and only after I finish the work to deploy it back.
How do I do it?
Thanks
Here are the steps that you should follow;
Connect to your local db.
Select Import Data-tier Application.
Select your .bacpac file.
Give a name to your new database and hit finish.
Create a new login or choose one of the existing ones and set the user mappings as follows so that you can connect to your new Umbraco db using this user's credentials.
And here is how you can connect to your local db from your local Umbraco website:
<add name="umbracoDbDSN" connectionString="server=localhost;database=YourNewUmbracoDbName;user id=youruser;password=yourpassword" providerName="System.Data.SqlClient" />
The .bacpac file is essentially a backup of another database, so you can't "open" or "connect" to it directly. You need to restore it on your local database server. Which, by the way, you might not have installed as it isn't part of Management Studio. When you open Management Studio you can just click Cancel on the Connect dialog that has your Azure server in it, and then maybe follow one of the many guides available via Google ;-) Like this one, maybe: https://www.netreo.com/microsoft-azure/how-to-restore-sql-azure-bacpac-to-local-sql-server/
Thanks a lot for your help!
I was able to install Umbraco locally.
Just one step I had to do before importing the database locally, is setup a local sql server, which I found a good explanation here:
Create Local SQL Server database
Create Local SQL Server database

Access to Azure SQL database returns unsupported keyword “metadata” error

I have an Azure Web App that accesses my Azure SQL Server database. Until recently (August 2020) the access worked without a problem but now it is not working. When I develop and test the app locally on my machine the read/write to the Azure SQL database is working, just not when I deploy the app to Azure.
I added the Web App’s outbound IP range to the Azure SQL Server firewall settings with no success.
I am using Entity Framework to connect to the database and want to continue doing so.
The error I get is:
"Keyword not supported: 'metadata'."
at System.Data.Common.DbConnectionOptions.ParseInternal
"The underlying provider failed on ConnectionString."
at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString
The test that it’s working would be to visit https://www.triviaweb.net/ and see a list of players in the scoreboard.
That connection string is only supported by Entity Framework. Use the below connection string and it should work. If it doesn't then try taking off ;application name=EntityFramework from the connection string.
<add name="Entities" connectionString="data source=tcp:dolaris.database.windows.net;initial catalog={dbname};persist security info=True;user id={user};password={psw};multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.EntityClient" />

Azure Active Directory Connection String

I've been trying to set up my IIS website's connection string to connect to an Azure SQL Database with the following connection string:
<add name="ConnectionString" connectionString="Server=tcp:some.database.windows.net,1433;Database=myDB;Authentication=Active Directory Integrated;" />
The IIS application pool is using a service account which has Azure Active Directory privileges and is added as an user on the Azure SQL Database.
This works fine on my local development machine (probably because it is using my credentials and not a service account) but when I place the site on IIS I get:
System.ArgumentException: Keyword not supported: 'authentication'.
Does anyone know the correct syntax for logging in via Azure AD?
Have you been through this troubleshooting guide, https://azure.microsoft.com/en-us/documentation/articles/sql-database-aad-authentication/#5-configure-your-client-computers?
In particular, do you have .NET Framework 4.6 or later installed?

Identity 2 code first database in SQL Express. Where is the database?

I want to create an MVC 5 project with Individual User Accounts authentication using Identity 2, and i want it to create a SQL Express database, instead of a localDb, using entity framework code first.
My connection string is as follows:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnet-MatWeb-20150821085043.mdf;User Instance=True;Initial Catalog=aspnet-MatWeb-20150821085043;Integrated Security=True" providerName="System.Data.SqlClient" />
When i run the web app, it launches properly and it let me register a new user, but if i try to check the database with SQL Server Management Studio, it doesn't appear anywhere.
So,
1.- Where is my database?
2.- Is it possible to make it visible with the SQL Server Management Studio? Or maybe change the database file path to make it searchable bu SQL Management Studio?
Thank you.
Since you attached your DB in connection string your DB is in App_Data folder of your project.
To manage your DB in Management Studio simply right click in Databases item in Object Explorer panel and choose Attach and add your DB file from App_Data

Windows Azure SQL Database Connection String Does Not Work When Solution Deployed

I have an MVC3 solution (EF 5/Net 4.5) that is connecting to a SQL Azure database. When I run the solution locally, it’s configured to connect up to the SQL Azure database, the solution works fine. However, when I publish the solution to Azure the connection to the SQL Azure database does not work.
It’s the same connection string in both the ServiceConfiguration.Cloud.csfg and ServiceConfiguration.Local.csfg files. I’ve also made sure that through the Azure portal the server that the Azure SQL DB is running on has “Windows Azure Services” as “Allowed Services” set to “Yes”
The connection string is:
<Setting name="SQLDataConnectionString" value="metadata=res://*/FooDB.csdl|res://*/FooDB.ssdl|res://*/FooDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=tcp:sahjjh7.database.windows.net,1433;Database=FooDB;User ID=<real user id>;Password=<real password>;Trusted_Connection=False;MultipleActiveResultSets=True;Encrypt=True;Connection Timeout=30;"" />
Any pointers?
Thanks!
I don't believe that Entity Framework knows how to grab connection strings from the ServiceConfiguration. Did you point it there yourself? If not, it could actually be an issue with a web.config transform.

Resources