Are Almaas
Are Almaas

Reputation: 1063

Azure SQL database working when running locally but not when published to Azure

My problem is very similiar with this problem on SO, but not quite.

When i connect to my azure database locally, it runs perfectly. But when i deploy to Azure, it seems it cannot connect to the database. I'm using Entity Framework 5 code first, and i have also set copy local:true on the EF 5 reference.

These are my connection strings:

    <add name="api" connectionString="
    Server=tcp:[hidden].database.windows.net,1433;Database=API;
    User ID=[hidden]@[hidden];
    Password=[hidden];Trusted_Connection=False;
    Encrypt=True;Connection Timeout=30;
    PersistSecurityInfo=True;" providerName="System.Data.SqlClient" />

    <add name="Membership" connectionString="
    Server=tcp:[hidden].database.windows.net,1433;
    Database=Membership;User ID=[hidden]@[hidden];
    Password=[hidden];Trusted_Connection=False;
    Encrypt=True;Connection Timeout=30;
    PersistSecurityInfo=True;" providerName="System.Data.SqlClient"/>

I added

    <customErrors mode="Off"/> 

in my web.config file so i could see the stacktrace, and these are the exceptions i got:

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
[InvalidOperationException: The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588]
[ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string.

When reading the stacktrace, it is certain that the problem is that i can't initialize the membership database. This have to be a Azure deploy issue, but i can't seem to figure it out..

EDIT:

The API-database is now working, but the membership gives the same error. I scaled the web site to be reserved instead of shared. Don't know if that could have any impact.

FIXED:

Well this is just strange.. Suddenly the web site has connection with both databases. Didn't do anything other changing the server from Shared to Reserved..

Upvotes: 3

Views: 1316

Answers (2)

hhaggan
hhaggan

Reputation: 619

Check the IP rules made on Windows Azure portal and make sure your current IP address is within the range you allowed to access the database running on Windows Azure

Upvotes: 3

viperguynaz
viperguynaz

Reputation: 12174

Make sure that your IP address is in the list of allowed IP addresses for the database.

Upvotes: 0

Related Questions