Named Schema not working in Azure SQL - azure

I want to use a separate/ named schema in an Azure WebSite app to implement a multi-tenancy in separate schemas pattern with Azure SQL. My app runs correctly in Visual Studio but not on Azure. I searched StackOverflow for similar issues, and found:
This answer suggests it can't be done: Multi-tenant application on Windows Azure. This question does not apply directly to named schemas: Azure SQL database working when ran locally but not when published to Azure.
For the MVC4 app I am developing I configured the Azure SQL database to use a named schema and modified the Connection String login name and password. When I tried to register the first user it threw the error message "Invalid object name 'UserProfile'" from Azure SQL. I checked the stack trace and everything looked reasonable so I reviewed the code for the SimpleMembershipProvider and did not see anything that should break when using a named schema.
As a Proof of Concept, I opened Visual Studio 2012 and created a new MVC4 app with .NET Framework 4.5 using the Internet Application template, which of course implements the Simple Membership Provider. I opened the Azure console and created a new web site with new database, then published the app to Azure. I ran the app and clicked the Register link to add the first user. This was successful, and I was able to logout, login, etc.
I then modified the PoC app's Azure SQL configuration by creating a new named schema, login and user. I added the db_owner role for the new user in the new database. I altered the user's default schema and transferred the tables created by the initial run into the named schema. I confirmed that the user's default schema is correct and the tables are in the named schema. I changed the user name and password in the Connection String section of the Publish dialog and again published the app from Visual Studio. I opened the website in Chrome and clicked the Register link. I entered a user name and password and got the error message "Invalid object name 'UserProfile'". I got the same error when atttempting to login with the user created in the first run.
I am looking for ideas about what to check next. I can work around this issue, but if I missed anything simple I would rather fix things the efficient way. Any ideas?

It seems I found a bug in Azure WebSites that causes the Connection String to not be updated by publishing the web site.
There is a connection string on the Azure Management portal's Configure page for the web site. This connection string is used to connect to the web site's database. It initially contains the User Id and Password used to create the database. Entering a different User ID and Password in the Visual Studio web site project (in Web.config or in the Publish Web dialog) has no effect on the connection string in Azure. This caused a problem in my specific situation, but would also be an issue for anyone who does not use the sa-like server-level user for accessing the database from the web site.
The workaround I found for this issue is to directly modify the Connection String in Azure on the web site's Configure page, instead of relying on effectiveness of a change in the Visual Studio project. This resolved the problem and now the named schema is working correctly.

Related

How can I deploy my database from SQL Server 2008 Express to Azure SQL Database

I am using Visual Studio Community 2013, SQL Server 2008 R2 Express Edition for an MVC web application using entity framework code first migrations for my database.
I am trying to get my local application hosted on the Microsoft Azure platform.
I have registered for a trial account which expires in 30 days, and deployed my MVC5 app out which has been successful.
However, this app requires a database which I am struggling to deploy.
What is the easiest way to get my database deployed out to Azure as I do not seem to have the :
"Tasks" -> "Deploy Database to Microsoft Azure SQL Database" option available to me in SSMS.
I have extracted a Data-tier Application of my local database and have it stored on my C drive, however if I connect to my Azure Account in a second window, and right click the server then select Deploy Data-tier Application, it fails on "Creating schema object in database" with the following error:
TITLE: Microsoft SQL Server Management Studio
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------ ADDITIONAL INFORMATION:
Users cannot be mapped to certificates, asymmetric keys, or Windows
logins in this version of SQL Server. (Microsoft SQL Server, Error:
40528)
I'm assuming its tried to create my local account plus the IIS APPPOOL account I had to set up to host the website on my local network, however I do not see a way of removing them from the .dacpac export.
When I refresh the Databases node, there is still no database, I'm fairly lost now as to how I might get my db deployed to this server?
If you can extract a compatible Data-tier application and then Deploy it to your target server using your current version of Management studio, then this approach should work, see this link for more reading on ensuring your database is compatible.
Failing this, as was in my case. I downloaded Management Studio 2015, which gave me the option to deploy database to Azure by simply right clicking the required database.
Again, this threw up the error regarding my database level IISAPPOOL user, but not my server account user. As a way around this, I took a backup/restore of the database and removed this user then deployed the copy database obviously minus the problem account.
Now all that was left to do was add a transform to my Release web.config with the Azure connection string as provided on the Azure dashboard, and re-deploy the website.
Problem solved.

Server error in '/' Application Visual Studio 2015 community

Need your help on this.I'm a newbie to the C# visual studio domain.
I was going over the tutorial on Microsoft site to create App and deploy on Azure. Here is the link below:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/
After completing every single step .I have this annoying error message that keeps popping up whenever I try to access/ login-in - by using the google account or using the default user name and password on the site. Screenshot here
I've gone line by line checking my steps and codes ;my azure server, app and database is running perfectly. Google API and app is running - no errors.
On my local machine it is works fine. But, when I publish the code to Azure - the home page comes up and I can navigate to the login page but - I just can't login-in using the google AuthOut nor the default login page using the default credentials on line.
For the life of me - can't understand why its not working. Need help people.
The error means that your site is trying to talk to your database (SQL Server) but it can't connect to it. You probably don't have a SQL server database setup.
Look at step 11 in the instructions:
11.Select Create new server, enter a server name, user name, and password.
I'm guessing that you didn't create the database when you were creating your web app.

Unable to connect to azure sql server

I created a new Azure Mobile App and set up my Sql Server database with it. I use an email address as the username, and then assigned a password.
Once the Mobile App and the Sql Server db setup completed, I was able to get my iOS app to target it and use the Azure authentication services without any issue. I then inserted some data in to a table in the iOS app, without any errors.
Now, I want to open the database and verify the data. Anytime I try to connect to the server using SSMS or Visual Studio 2015, I am told that the login failed.
I use an email address like Johnathon#MyCompany.com. When the sign-in fails, it says:
Login failed for user 'Johnathon'.
Is it the email address for a login causing issues? My ISP blocks port 1433, so I thought that maybe that was the issue initially. So instead of using VS or SSMS, I moved to the web-designer on the Azure portal. When I sign in there, I receive the same error. This has occured across three different App Services setups. I tried using the older Mobile Services, and had this issue. I then moved to the newly released Mobile App Service but have the same issue. Each time I deleted the database and recreated it and the server.
I have also added my client IP to the azure sql server firewall.
I'm at a loss at this point.
Update
I have managed to sign in to the server within the Azure portal designer by omitting the database name. However, when I select the Design option, and then click the Design button on the database, I receive a Failed to create context error. I assume this is related to why I can't connect to the server when I specify a database name in the Azure portal.
As a note, having the # symbol in the SQL Azure login tends to cause a number of headaches and it is not recommended to have it in there. What you will notice is that SSMS and other applications try to use it as part of the server name which then causes context and other failures.
The easiest fix for this is to roll up another SQL Azure server with a login name that doesn't use the # symbol, you will have a better experience overall.

Azure Tools for VS - can't sign in to subscription

I'm having a pretty strange issue with Azure tools for VS 2013 (version 2.6). Whenever I try to sign in to my Azure subscription (e.g. from Server explorer or creating a new web role project) I get the following error:
Server Explorer
An error occurred during the sign in process: User 'foo#gmail.com' returned by service does not match user 'bar#outlook.com' in the request
OK
My subscription owned by 'bar#outlook.com' and I can perfectly fine sign in either to management portal in a browser (IE, Spartan and Chrome) - as well as in the Power Shell. Tried everything - cleaning up browser caches/cookies, resetting IE settings, playing with different IE security settings - nothign works.
Any help is appreciated - this issue drives me crazy.
P.S. I'm on Windows 10...
I had the same problem. Imported the certificate manually and everything worked ok: https://social.technet.microsoft.com/Forums/en-US/9cdafeb4-f459-436d-b2b8-9bc5c01f0df1/azure-tools-for-vs-cant-sign-in-to-subscription?forum=windowsazuredevelopment
I had this issue, to resolve it I:
Added 'foo#gmail.com' as an alias in my 'bar#outlook.com' Microsoft account, via account.live.com
Made the 'foo#gmail.com' email address the primary alias for my Microsoft account
I could then log in successfully in to Azure by pressing the Connect to Microsoft Azure button in the toolbar of the Server Explorer in Visual Studio 2013 and see all of my websites under the App Service node.
(When I'd used the certificate method described in the other post and Microsoft documentation I'd been able to see all my sql databases etc. but not the websites.)
Once I'd done all that I then switched my primary alias back to 'bar#outlook.com' and server explorer carried on working.
NB: If you're experimenting with this beware that there is a limit on how many times you can switch your primary.. as I have just discovered.. and now my primary is stuck on the wrong email address for a week.
NB2: If your connecting in order to be able to remote debug the website, then this can still be done by going to Visual Studio>Main Menu>Debug>Attach To Process, and then enter the URL of the site (without the http bit, e.g. mysite.azurewebsites.net) as the Qualifier and then attach to the w3wp.exe process.
I am having the exact same issue. It seems that the Azure sign-in in Visual Studio is redirecting to our organizational Single Sign-On instead of the Microsoft one. I have managed to work around this problem by using a Microsoft account that is not tied to my organization:
Create new Microsoft account or use an existing account not associated with your organization
In https://manage.windowsazure.com select Subscriptions/Manage Administrators
Choose Add+ and add the new Microsoft account as administrator to your subscription
Log on to Azure using the new account from Visual Studio
/Morten
I changed my Microsoft account's email address and had this problem. Adding an alias did not help.
The problem is to do with the Azure Active Directory Library for DotNet. For whatever dumb reason, they throw an exception when Azure returns an ID different than the one requested (if the server isn't crying about it, why make up an error and make the client deal with it?).
Since Azures's support was no help, I had to build a custom copy of the ADAL with that moronic exception removed and an assembly version matching the one used in VS2013 (2.11). Also importantly, disable strong name verification for the custom assembly.

Azure - Changed admin password for DB and now can't access database

I have a Azure account and have deployed an MVC app.
I changed the admin password for the db and updated my web.config accordingly and after I've published the app, the app can't access the db. I get the following error:
Login failed for user 'xxx'.
This session has been assigned a tracing ID of '11a7a162-ff21-42f0-a8ea-8e5ce25b8ab6'.
Provide this tracing ID to customer support when you need assistance.
Any help appreciated. I've been over everything with a fine toothcomb and I can login to the db using SQL Management studio using the new credentials. The DB is dead however.
The only other thing I did was change the size of the DB from 1GB to 5GB.
I managed to fix this and for anyone out there, here's the gotcha. Even when I changed the connection strings in the publish profile, they were ignored. I had to go to the Azure portal and change the connection string settings against the deployed web app directly.
I wonder whether this is a bug with Azure. I would have expected my publish profile settings to change the connection strings on the deployed application.

Resources