Connecting asp.net Identity to SQL Azure - c#

It seems MVC 5 no longer uses simple membership and I am having trouble figuring out how to use a SQL Azure database instead of the default .mdf file that is generated and saved on the web server. In simple membership it was as easy as changing two connection strings but that does not seem to be the case here. From what I have found online, it seems like I have to create my own custom storage provider to accomplish such a simple task. The only examples and docs I find online that deal with Azure are scenarios in which the developer wants to store in a non-relational setup or Azure Table storage.
Am I right in the above conclusion or is there something I am missing about integrating SQL Azure DB into my MVC 5 Asp.Net Identity app?

I have Identity running on top of a SQL Azure DB in one of my projects. You don't need to implement your own storage provider. The only thing you have to do is to change the connection string (normally named DefaultConnection) in your web.config file and point it to your SQL Azure DB.

Related

How To Backup Microsoft Azure SQL Database Using ASP.NET

Good day, I am trying to backup a Microsoft Azure SQL database using an ASP.Net application programmatically into either a .BACPAC file I can download to a local machine or into an Azure blob storage platform. I know similar questions have been asked before but I have searched the web and cannot find a recent solution that seems to work. A simple "Backup database" SQL query also doesn't seem to be possible as I am constantly thrown with the error message: 'BACKUP DATABASE' is not supported in this version of SQL Server. Any help would be greatly appreciated. Attempt at consuming API
The simplest way i think is to use Databases - Export Rest Api(Exports a database to a bacpac)
The rest api provides you with a blobUri which you can use to download or transfer to Azure blob storage

Implement new IdentityServer in .NetCore MVC with existing UserDb

I would like to create a new IdentityServer4 for a .NetCore MVC Project without ASP-Authentication, which gets the users from an existing MS SQL-database.
The user database should not have to be changed, if not necessary.
Unfortunately, previous tutorials could not help me, because a lot has been revised.
What steps are necessary to achieve this?
Hope you can help me,
best regards
The Identity server i am currently working on used to connect to a MsSQL server database that contained legacy users. The identity server itself stored its own tables in its database. I believe the way it worked was it had its on UserDbContext added to the middelwere.
So what we had was.
Identity server database - clients and stuff
Legacy user database - All user data.
Which is close to what you are talking about
services.AddDbContext<UserDbContext>(builder => builder.UseSqlServer(settingsSetup.ConnectionStrings.UserDatabaseConnection));
Everything ran though a custom UserManager.
It no longer runs this way as over the summer i integrated all of the users to Asp .net core identity and the data now resides in the same database as the identity server.
I can dig around in the solution control old branches if you need more info.

Is it bad practice to create the AdalTokenCache as an SQL Database in Azure?

My MVC web application uses Azure AD Authentication. Initially when you run the wizard on your project to set this up for you it creates an mdf database file in your project for the AdalTokenCache. This isn't compatible with Azure as you can't use local MDF files.
What I have done is created the AdalTokenCache as a database in my Azure portal and I'm using that instead (which works fine). My question is, is this bad practice and if so what's the best way of handling it?

How to put database on azure website

I recently finished my asp website, bought the domain and azure hosting. Unfortunately, when I try to do anything that accesses the database I just get stuck on a loading screen. I just used the default asp razor mvc 5 project I think for the database along with a couple of custom tables.
So here is how I would do it since you have an existing database. I would follow azures website, and set up a SQL database. I would then script out the database on you local machine, and log into your azure database using SQL Server Express. Execute the script you generated from localDB. Then all of your data will be good to go. You will then need to take the connection string from azure, and put it in your applications config file. After modifying the connection string in your application you should redeploy, and verify everything is working the way you want. You will be able to verify your data is there in SQL Server Express.
Here is a link that may be of quite a bit of assistance to you. It includes step by step instructions as well as screen shots.
Another option is using this tool. I have never used it, but I know a few people who have had great success with it.

Creating ASP.NET website with membership database in server

I am trying to find out how I can add the membership database to my Mircroft SQL Server and then be able to reference it from a ASP.NET application. Basically, I created a new website app project, how do I create the asp_net membership database and then tell my website to comunicate to it?, I found this
http://msdn.microsoft.com/en-us/library/879kf95c.aspx
But that is not what i want, it creates a database file in the App_Code folder, I want it to access my Microsoft SQL Server and then there have such database. I am new to this setting up login merbership stuff and some pointers would be of great help. I thought maybe there was like a wizard where you could specify the server etc..?
Regards
There is a really nice Walkthrough of that here. You just need to use aspnet_regsql.exe to create the necessary objects in SQL Server and use Membership provider settings to use this new connection string, it is explained here under the Step 4: Specifying the Provider and Customizing Its Settings.
Hope that helps.
Cheers

Categories

Resources