web app with local db .mdf file how to publish to Azure - azure

I have a web app published on Azure.(created locally via visual studio)
I ve also migrated my main Database(Azure Sql database) and connected with the web app and of cource already created an sql server instance.
My problem is with my local db file .mdf file in my App_Data folder.
When i published my app returned error below:
provider: SQL Network Interfaces, error: 52 - Unable to locate a LocalDB installation. Verify that SQL Server Express is properly installed and that the LocalDB feature is enabled.
How to attach .mdf file ? and associated it with my sql server instance?
Thanks

I think you can't use SQL Server Express (pretty sure there is no Express installed). Why do you want to use SQL Server Express?
Anyway, you can migrate it to Azure into SQL Server Compact - http://www.asp.net/mvc/overview/older-versions/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-deploying-sql-server-compact-databases-2-of-12
But that way is not very efficient if you plan to implement any type of replication - any instance will have own db - and some other drawbacks.
I believe that the best way here is to use SQL Azure and migrate your data into it if there is no need in something like SQL Server Compact/Express.

Related

Azure database file location

There is Azure SQL server with name xxxdb10.database.windows.net that is up and running. I am trying to create DB there and I have to use specifics application in order to have proper DB structure. Everything works with SQL Server Express as you can see below, program add file location automatically. But when I try to point to Azure SQL server and do the same application does not recognizance path and I got this error below. What to use for database file location in case of Azure SQL server please, can you help?
With SQL Server Express:
With Azure SQL server:
• I would suggest you use Microsoft SSMS (SQL Server Management Studio) tool to connect to the Azure SQL Server created in Azure instead of SQL Express. Since SSMS is only a tool for managing various types of SQL Databases locally or in Azure, thus it should be promptly used for creating such Azure databases. Please refer the link below on detailed documentation and information regarding this as well as refer to the snapshots depicting the usage of SSMS as a prompt tool for connecting to Azure SQL databases and server.
https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-ssms
In the above snapshots, you can see that we can connect to an Azure SQL Server and creating a database in it through SSMS.

How to import existing database on Azure?

I have completed with the process of creating webapp + mysql with different deployment slots. I have also configure bitbucket on Azure new portal (https://portal.azure.com). I have Linux system.
I want to import existing Database, from local to Azure. I have tried with Mysql workbench but its giving me Failed connection.
So my question is, How to import existing Database on Azure portal?
In regards to your comment from yesterday, you either try to connect to an Azure SQL Database with the MySQL Workbench, which will not work.
Use another tool like SQL Server Management Studio or JetBrains DataGrip for that.
Or you're using the ClearDB MySQL offer.
Then your connection string should look like this "Server=eu-cdbr-azure-north-b.cloudapp.net;Port=3306;Database=myDataBase;Uid=myUsername;Pwd=myPassword;", which I was assuming when you wrote that you used the webapp+mysql template.
Or you're hosting your own MySQL Server as a Virtual Maschine, which would also be a different server name, e.g. yourpublicipdnsname.northeurope.cloudapp.azure.com

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.

Issue connecting to SQL Express

I have two visual studio 2010 projects that I am running locally. One is a cloud project and connects to azure table (development) storage in addition to a local SQL Express, the other is not a cloud project. Both projects attempt to connect to a local SQL Express database via similar code generated through an xsd as well as directly in an aspx via a databound grid. The non-cloud project connects fine, but the cloud project fails with the common error:
"An attempt to attach an auto-named database for file C:\Users...mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
Both projects use the same connection string in a Web.config file:
<add name="WorkoutLogConnectionString1"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\...mdf;
Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
In VS2010 server explorer from the cloud project I can connect to the express database just fine, but when the project runs, it fails to connect. The cloud project also connects to a SQL Azure remote cloud database via another connection string in Web.config and that connection works fine.
I saw the MS support article: http://support.microsoft.com/kb/2002980 and thought that maybe the projects were originally created with different versions of VS and that maybe causing my issues, so I made the suggested IIS changes to the ASP.net 4.0 application pools, but to no avail.
Since the SQL Express connection string works in one project and not in the other I am stumped. Are there some other configuration elements or something related to the failing project being a cloud project that I should be looking at?
Are you tyring to run both the project simultaneously (at the same time - multiple startup projects). If so, it is indeed common issue with SQL Express. Often happens also when you have opened the database in your VS Server Explorer. If you have multiple applications accessing the same database, I suggest that you manually attach the database in your SQL Server Express. You can do by:
open SSMS (Sql Server Management Studio), connecting to your local SQL Express instance.
Navigate to Databases branch
Right click -> Attach Database
Browse to your mdf file
Done!
Now change your connection to the one suggested by Aaron. Generally I advice to now use the AttachDbFilename and UserInstance, but instead attach the database directly and use it as with a regular stand-alone instance of SQL Server. Saves lots of headaches.
Have you attached your database to an actual SQL Server Express instance? If so, remove all that AttachDbFilename and User Instance nonsense. To keep things simple and consistent you could probably use SQL Authenication locally. So you should just have something like:
<add name="WorkoutLogConnectionString1"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=DatabaseName;
User ID=SQLAuthUsername;Password=password" providerName="System.Data.SqlClient" />

Migrating from "SQL Server" to "SQL Azure, while already using "Linq to SQL"

I want to migrate an existing application from SQL Server to to SQL Azure. I am using "Linq to SQL". The application is local, what i assume is that i will only have to change the connection string and the application will be connected to the cloud instead of local database and no change is required at code level.
If you already have your database migrated to SQL Azure, then yes all you will need to do is change the connection string and open the SQL Azrure firewall to allow your clients to access the DB (this you can do in the portal).
However, while SQL Azure is very close to SQL Server, it isn't exactly the same. Lots of links to official variations can be found in this article or you can try running the SQL Azure Migration Wizard

Resources