getting simple membership to work with azure web sites
Asked Answered
L

2

6

I am wanting to use the simple membership providers as if i was connecting to a local mdf file for this mvc project, except i want the memebership tables on the free azure trial db

UserProfile
webpages_membership
webpages_OAuthMembership
webpages_Roles
webpages_UsersInRoles

how should the connection string look for making this connection.

when connecting locally to a local mdf it works like the cats ass, but trying to get the tables built on azure is not well documented.

anyone done this?

ok i needed to make sure the conn string name was the same as the one being passed into the WebSecurity.InitializeDatabaseConnection method of the Filters > InitializeSimpleMembershipAttribute.cs file, by default it is DefaultConnection so it must align with the connection string you give it in azure db conn string.

so now i have f5'd out of VS and the tables get created, i even locally tested my facebook login and it works.

but... when i deploy the application to azure web sites, the site times out with a 504 error like it can't connect to sql, this happens to me for both the sql database within Azure as well as i spun up a virtual server that had sql installed and enabled the tcp port 1433 - like i said this works locally when i run out of VS, just not up on the azure cloud.

i get Error.

An error occurred while processing your request.

fiddler shows it as a 504 error gateway timeout. Anyone got an mvc 4 site running on Azure with the simple login membership api?

Laflam answered 24/11, 2012 at 2:11 Comment(1)
+1 for the description on how it works locallySchouten
L
5

ok there are 2 places the connection string needs to be changed, the one from the InitializeSimpleMembershipAttribute.cs and the one in the AccountModels.cs file public UsersContext() : base("DefaultConnection") { } swap out DefaultConnection with your conn string name

Laflam answered 26/11, 2012 at 15:54 Comment(1)
Thank you Biz! I spent nearly an hour perplexed until I realized this small mishap.Spicebush
A
0

There are two things you need to do. One is to get the connection string from Azure. Go to the Dashboard for Azure for your database. You should see a "Show connection strings" link. Click it and copy the ADO.NET string.

You also need to enable access to the database from the IP address of your test machine. There is another link on the Dashboard called "Manage Allowed IP Addresses". Click that and add the IP address.

I just replaced the DefaultConnection string in Web.config with the one I got from Azure and it worked. It even works from my test machine as long as I get the IP address in the portal.

Alicealicea answered 16/5, 2013 at 6:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.