Connection Error with SQL Azure and Entity Framework on Azure Website - sql

Not sure where to start, but whenever I publish my ASP.NET website to Azure, any pages which have database access give me a message saying "Error. An Error occurred while processing your request." I open up the remote debugger (which is fickle because it refuses to attach half of the time) and I see the error occurs when establishing when trying to access Entity Framework. The error varies between a "network-related or instance-specific" error, or a "Login Failed" error (which could be the result of the previous error, I really don't know).
The ADO.NET connection string SQL Azure gives is
Server=tcp:[servername].database.windows.net,1433;Database=EnsembleMusicWebDatabase;User ID=user#[servername];Password=(password);Trusted_Connection=False;Connection Timeout=30;
But every implementation (inserting that into EF metadata string, changing the server to data source...etc) still gives me the same login error
I'm pretty sure it's a problem with the connection string, but the infuriating part is that I've tried every possible combination I can think of (entity framework metadata, using the SQL Azure database ADO.NET connection strings in any possible way, changing the Azure website connection strings under the Config tab, using just a plain connection string...etc).
I've deleted and rebuilt the Entity Framework models at least 5 times, and every time I can successfully establish a connection to the server and it successfully reads my database and creates the correct models. I deploy the application to localhost and it works. The problem is when I publish, it cannot access the database and keeps giving me these login failed errors (the login details are the exact same as when I set up the EF model).
I think it might be something to do with the firewall, since I can access the DB locally with an approved firewall IP on the server config, but the website itself can't access the database (I have the enable azure services box ticked as well). I'm really at a loss for what to do now, because I just want the site (not any user, just the application) to fetch some data from the database and display it on the page, but I don't understand how this could be so complicated.
Can anyone point me in the right direction? I tried every tutorial and example on msdn and I can't find any solutions on SO that work.
Thanks,
Shaun

I realised that I somehow got into a complete mess with connection strings all over the place and the best way to fix it was just to start again. I deleted my Azure website and database instances, built the database first (created a correct login as well) and then when creating a new website Azure gave me the option to include the database I had just created. I now have a correct connection string that Azure generated, but to be safe (because the metadata made connection strings confusing and I didn't want to risk having this same issue again) I'm not using Entity Framework and just using normal SqlClient queries, since the website only requests two objects from a database.
I think now I've got a correct and working string I can look at it and really understand where I went wrong and how to avoid this if I do end up using Entity Framework.

Related

How to delete a corrupt database from azure sql

I have tried to delete a SQL database from the azure portal. It looks like it has failed part way though. The database doesn't show up under the list of SQL servers in the Azure portal. However if I login to the server through SSMS it is still there. I now can't delete the database or create a new one with that name.
I've tried deleting the database with a query and get an error saying the database doesn't exits. If I try to create it either from the Azure portal or SSMS it gets an error saying it already exists.
I had a similar problem once, with SSL settings, where it would return that it is linked to the app even tho it wasn't, hence I was not able to delete it. After a couple of weeks of back and forward with the support, we removed it through azure resource explorer.
How to:
Once you are logged in, set read/write
In serach box find your resource
Click actions (POST/DELETE) // these should be available now since you have set read/write
Click Delete
Hopefully, this would help anyone who has any corrupted resources in Azure.

How to fix "login failed for user" when manipulating SQL database in Azure from a .NET Core webapp?

I have an SQL Database in Azure and a .Net Core web app in which I would like to manipulate the database using Entity Framework Core.
I believe I have all the model, data and controller classes needed for this, and I have a few sample objects I'd like to see in my database.
My problem is that no matter what I do or how I want to manipulate the database, I always get the error "login failed for user", yet the login info is an admin and I believe I set up everything that is needed.
I see the database in the SQL Server Object Explorer, I can connect to it using SSMS or simply on the Azure Portal, and there seems to be no problem with my connection string. The username&password combo is fine, I've checked it multiple times, my IP is enabled in the firewall of the database, I have no idea what could be the problem, please help me!
Here is the error:
The problem is solved now, it was a very tiny, stupid error:
the connection string I copied from the Azure site was waiting for an escaped field, assuming I won't write my username and password manually, which of course won't be happening in the future, I just wanted to test if the whole stuff worked as this is my first project in this area.
So the Azure connection string looked like this: USER={XY};PASSWORD={ASD} but I left the curly brackets in the string even though I didn't use a variable there.
I test and it works fine. So I am doubt about whether you could run it in local with the connectionstring of Azure sql database.
Open your azure sql server on portal and click your sql database.
Click the Connection string and copy the connectionstring. Filled into your username and password.
Then put it to the connection string in appsettings.json on visual studio.
If you could run on local, then you publish will have no problem.
Also, you could follow this article to learn with asp.net core mvc.

SSRS 2012 - uninitialized server

I have been experiencing random connection/handshake problems w/ a hyper server VM running SQL and SSRS
So the network guys suggested building a new VM and trying it there. (Have you tried rebooting? )
I asked that they rename the old server (--> SQLBKUP) and name the new server to the current name (--> SQL) so all my connection strings will continue to work.
Regardless the wisdom of that approach, that is all now done.
All of our applications work. (and the weird handshake issue is gone,joy)
I have reinstalled SSRS and I thought I was home free.
We backed up and restored the ReportServer and ReportServerTemp databases to the new server.
If i try to point to these databases , I keep getting this error
The report server installation is not initialized. (rsReportServerNotActivated) Get Online Help
Any all information I can find about this for 2012 says that the initialization happens automatically when you configure a database.
I tried creating a new database, and presto, everything works fine.
I reconfigured SSRS to point at the old database and I again get the rsReportServerNotActivated error.
I also 'powered down' SQLBKUP in case it was causing some confusion, I cant imagine what that might be, but why not... This did NOT correct the problem.
Any ideas on why the databases that were working on 1 server wont work on the new one?
Searching the interweb for this issue I find two results for 2012 SSRS (many hits for 2005 issues/resolutions )
this article details how the RSExec role should be configured, I have verified that is all correct.
https://msdn.microsoft.com/en-us/library/cc281308.aspx
this article details the mechanics of various ways to move a database. The back up and restore operations went off w/o a hitch.
https://msdn.microsoft.com/en-us/library/ms156421.aspx
neither article mentions cleaning up any server names, ip addresses, etc. that might be in a config table. Inspecting the tables in SSMS, I dont see any tables that look like they might need such attention.
I can always recreate the environment, I am aout to that point, at least I will know what I have in front of me. If anyone has any suggestions, i would appreciate it, Im sure I will be up for a while... :-)
tyia
greg
You are getting that error because you haven't moved the old encryption keys to the new server. SSRS uses encryption to secure credentials and connection information. You'll need to get the encryption keys from the old server and restore them to the new one OR if you don't have the keys anymore you can create new ones but you'll need to setup your connection information again.
First backup your old encryption keys:
Start the Reporting Services Configuration Manager, and
then connect to the report server instance you want to configure.
Click Encryption Keys, and then click Back Up.
Type a strong password.
Specify a file to contain the stored key. Reporting Services appends a
.snk file extension to the file. Consider storing the file on a disk
separate from the report server.
Click OK.
Then restore the keys to the new server:
Start the Reporting Services Configuration Manager, and then connect to the report server instance you want to configure.
On the Encryption Keys page, click Restore.
Select the .snk file that contains the back up copy.
Type the password that unlocks the file.
Click OK.
You can also use the rskeymgmt utility, see the MSDN article: Back Up and Restore Reporting Services Encryption Keys.
If you don't have access to the older server you'll need to delete and recreate the encryption keys. Once you delete the keys the server will automatically re-initialize itself and you'll need to re-enter all of the lost encrypted information.
The following things will occur when you delete the encryption keys:
Connection strings in shared data sources are deleted. Users who run reports get the error "The ConnectionString property has not
been initialized." Stored credentials are deleted. Reports and
shared data sources are reconfigured to use prompted credentials.
Reports that are based on models (and require shared data sources configured with stored or no credentials) will not run.
Subscriptions are deactivated.
Steps to delete the keys:
Start the Reporting Services Configuration tool, and then connect to
the report server instance you want to configure.
Click Encryption Keys, and then click Delete. Click OK.
Restart the Report Server Windows service. For a scale-out
deployment, do this on all report server instances.
This is from MSDN - Delete and Re-create Encryption Keys. The article has a lot more useful information.
For more information also read Configure and Manage Encryption Keys

SSAS anonymous access Cross Domain Access

I'm trying to configure anonymous access to SSAS accross domains. Well at least that is what I think I need to do to solve my business problem. I've attempted all the steps on here
http://support.microsoft.com/kb/324040
http://www.ssas-info.com/analysis-services-faq/29-mgmt/2670-q-how-to-setup-ssas-anonymous-authentication-to-access-data-from-internet-or-another-domain
to no avail.
Let me explain my situation I've got a SQL Server running SSAS and then a development server with access to database server. I would like a user that doesn't have access to SQL server box to be able to open Excel spreadsheets that connect to the SSAS server. So they can browse the data. I've found that the user on the development server also has to be the exact same user name and password on the SQL server. This might not be the worst solution I was just wondering if anyone knew about a better way.
On another note being a bit of an SSAS newb what is the best way to expose a data cube on the web? Any good resources for this would be very helpful.
If the user doesn't have credentials on the SSAS server I get this error
"An error was encountered in the Transport Layer" Followed by this ever so informative error
"Errors in the OLE DB provider. An error occorred while loading the connection dialog box component for prompting."
Thank you

Problem writing to a SQL Server 2005 Database from MVC2 App hosted on IIS6

As the title indicates I have an MVC 2 Application running on Server 2003. So, I have IIS6 and a SQL Server 2005 instance on another machine that I am connecting to.
Here's the scoop:
--I have done the wildcard hack to get the MVC routing to work and the site loads correctly.
--I can read information from the database and everything displays fine. (So MVC is working)
--I am using Linq to SQL.
--When I attempt to update data in the database I get an internal server error.
--The website runs correctly and will read and save information to the same SQL server instance when running from Casinni or IIS Express on my development machine.
Some other possibly useful information: I am using Windows Integrated Authentication (the website sees me as the user correctly), the app pool on IIS is running as a user who has both read and write access to the database. I also currently have anonymous authetication turned off, but turning it on caused no change.
Any ideas would be really appreciated. I feel like it's something really simple that I am just missing.
So after long hours on the phone with MS tech support here is the answer:
So if you have a database that contains two tables, both with automatic integer primary keys, and a relationship exists between a unique char field in one and a non-unique char field in the other, inserting new rows into the second table leads to invalid case exception. This exception does not happen when calling to the database from Cassini, IIS7.5 Express or IIS 7.5 but does from IIS.6.0.
I restructured the database to avoid this design architecture and the problem was resolved.