Internal error import BACPAC file to windows azure sql database - sql

I am using MSSQL2014 version CTP2.
Running my databases through Windows Azure SQL Database management.
I've created a BACPAC file via MSSQL of my local database and want to import it to Windows Azure.
I create the BACPAC file and upload it to my BLOBSTORAGE container.
In Windows Azure click SQL DATABASES
Bottom left click New
Click IMPORT
Choose my BACPAC URL which is the file contained in my BLOBSTORAGE
Name the DB and choose the server
Click the tick
I then get this error:
Error encountered during the service operation. Could not import
package. Internal Error. The database platform service with type
Microsoft.Data.Tools.Schema.Sql.Sql120DatabaseSchemaProvider is not
valid. You must make sure the service is loaded, or you must provide
the full type name of a valid database platform service. Internal
Error. The database platform service with type
Microsoft.Data.Tools.Schema.Sql.Sql120DatabaseSchemaProvider is not
valid. You must make sure the service is loaded, or you must provide
the full type name of a valid database platform service.
I can create a new database via Windows Azure which is fine but I'm trying to get my DB up because it has all my data in it.
What am I doing wrong?

I believe the issue was that I needed to assign the same DB owner to my db on my local machine as the one that was setup on my azure setup.

Related

Moving SQL Data into Azure SQL PaaS

I have a database in the SQL Server installed on Azure VM. DB Size is 2 GB.
How and what is the best approach to move all data into Azure SQL PAAS Service?
While the method posted by #Harris Xu is absolutely correct, I am adding the issues which I faced when I migrated my 500+ GB SQL Server DB from Azure VM to PaaS using .bacpac method.
Azure SQL DB is in a away limited when compared to On-prim SQL Server or SQL Server on VM's.
You will not face these issues while creating the .bacpac file but when you try to import, it might give some of the following compatibility issues.
Master Keys , Symmetric Keys, Service Queues and certificates cannot
be migrated to cloud. Drop them before preparing bacpac.
Drop orphaned Users.
If you are using XP_CMDSHELL, Trace Flags, DBCC commands or column store indexes, you got to remove them too.
Cross DB Queries are not allowed on Azure SQL DB. Remove all occurrences of ..
If you are calling an API from your stored proc then that too is not possible in Azure SQL DB. As a workaround you can use Logic Apps on Azure.
Moreover, Microsoft Migration assistant can help you find compatibility issues before hand too. You can download it here.
NOTE : This no way the full list of issues, I faced them because I was using all above features, if you are not using them you will not face them.
SQL Migration using data-tier application export/import (BACPAC)
The BACPAC file encapsulates the database schema as well as the data stored in a database application that can be simple imported to an Azure SQL Database.
Workloads using the source database need to be taken offline during the export process to ensure that the exported BACPAC file contains all data in a complete and consistent state.
Export to bacpac file in SQL Server Management Studio (SSMS)
You can follow this post.
Open and connect database file in SQL Server Management Studio (SSMS).
To export a database file, right click on the name of the database. In the context menu, select Tasks > Export Data-tier Application.
The option will open the wizard. Click Next> Introduction page and go to the Export Settings.
Import a bacpac file to Azure SQL
After you connect to your Azure sql, go to Object Explorer pane, right click the database, and select Import Data-tier.
The option will open the wizard. Click Next> Introduction page and go to the Import Settings.
The Import settings are requested to the bacpac file to import.

Cannot open backup device - SQL Server on-premise backup database to Azure storage

I have a database running on an on-premise SQL Server instance. I've set up a SQL agent to backup the database every night and store in a container in Azure. However, I'm seeing the following error after the job runs:
Message
Executed as user: NT SERVICE\SQLSERVERAGENT. Cannot open backup device 'https://mystorageaccount.blob.core.windows.net/mystoragecontainer/20200102/MYDATABASE_0.bak'. Operating system error 50(The request is not supported.). [SQLSTATE 42000] (Error 3201) BACKUP DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013)
The Azure storage account is Storage (general purpose v1).
SQL Server 13.0.5233.0
Microsoft SQL Server Management Studio 14.0.17213.0
Microsoft Analysis Services Client Tools 14.0.1016.232
Microsoft Data Access Components (MDAC) 10.0.14393.0
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 9.11.14393.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 6.3.14393
Is there a way of configuring NT SERVICE\SQLSERVERAGENT to connect to the Azure storage container?
All the comments are valid to a certain extent. I finally fixed (term used loosely) backing up my SQL Server database to an Azure storage container using SAS (shared access signature) credentials.
Deleted the existing credential in SQL Server (under Security > Credentials)
In Azure, created an access policy under Storage Account > Container. It's important to define start and expiration dates/times, and time zones along with read, write level.
In Azure, Generate a SAS token for the container. Ensure you set the appropriate start and expiration dates/times along with the timezone. Don't rely on just UTC.
Upload a file to the container to make sure it's all ok.
In SQL Server, create the credentials. The secret should be the SAS token without the preceding ?, so just "sv=...." .
IF NOT EXISTS
(SELECT * FROM sys.credentials
WHERE name = 'https://mystorageaccount.blob.core.windows.net/mycontainer')
CREATE CREDENTIAL [https://mystorageaccount.blob.core.windows.net/mycontainer]
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = 'sv=_my_sas_key_without_?';
Backup the database. The URL and container must match with the credentials - in this case, https://mystorageaccount.blob.core.windows.net/mycontainer .
BACKUP DATABASE [mydatabase]
TO URL = 'https://mystorageaccount.blob.core.windows.net/mycontainer/mydatabase_03012020120400.bak'
WITH FORMAT,
COMPRESSION,
STATS=5,
BLOCKSIZE=65536,
MAXTRANSFERSIZE=4194304;
GO
This seems like access related issue.To be able to back up to Azure Blob Storage, your backup command must have a valid credential that has access to the blob storage. This can be done in two ways:
Review your credentials, make sure your access key is correct and, if you’re using SAS, make sure that the access policy is defined and you are pointing to the correct container that it has access to. For more information on URL backups as well as script samples, please refer:
https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-to-url?view=sql-server-2017
Shared Access Signature
Identity and Access Key
Additional reference:
https://blog.pythian.com/how-to-fix-sql-backup-to-url-failure-operating-system-error-50/
Hope it helps.

How to setup local database from remote database in visual studio asp.net project?

I am working on an ASP.NET project which accessing a remote SQL Server database. My objective is to set up this remote database on my local system.
I have tried 2 ways, but I'm facing problems both ways:
(1) Using SQL Server import and export wizard.
I get an error saying that the connection state is closed, but I am able to fetch all database tables of remote database:
(2) Schema and Data comparison from SQL Server object explorer inside of Visual Studio.
Here I get an error in that database user-related issues are showing. User or group not found:
I have tried other things in the last 4 days also but not found any clue to solve it. I am new to ASP.NET and SQL. Please help. Any helpful answer will always be appreciated. Thanks.
I have tried the Dennis1679's answer, but the following issues are coming.
One or more unsupported elements were found in the schema used as of
a data package. Error SQL71564:Error validating element[username]:
The element[username] has been orphaned from its login and cannot be
deployed.
Install SQL Server Management Studio, connect to the remote database, right-click on the database, choose export data-tier application. Then connect to your local instance and import data-tier application.
Connect to the remote database:
Right-click on the database choose export data-tier application:
Follow the wizard and save the .bacpac somewhere
Connect to your local SQL Server (localdb)\MSSQLLocalDB
Choose Import data-tier application
Select the previously saved .bacpac and import it. Now your local instance should have the same database

Import into Azure - Could not import package, Unable to connect to target server

I am trying to move a small database from the SQL Server Express on my PC to SQL Azure.
I exported the BACPAC file successful to a storage container. On Azure side, I + New, Data Services, SQL Database, Import and used the UI to select the BACPAC file in the storage container. I gave the database a name and selected an existing SQL Server in my subscription.
After a minute or so, I get:
Import database 'xxxx' failed
Successfully retrieved the BLOB storage access key.
Successfully submitted the import request: operation ID 14a9d202-4a22-4b41-beae-cca2ddb877c8.
Import database 'xxxx' failed
Error encountered during the service operation. Could not import package. Unable to connect to target server.
What does the error message mean and what target server is it referring to?
When submitting an import request for Azure SQL Database, you will need to select the source BACPAC file from an Azure Storage container, and provide the SQL Authentication to log in to the SQL server you are trying to import into. The import operation will proceed as follows:
Attempt to retrieve the BLOB (aka the BACPAC file) from Azure Storage.
Submit the request to Azure SQL.
Attempt to log in, with SQL server authentication, to the target database server you want to import into.
Create an empty database to import the BACPAC file into.
Run the import operation to insert all data from the BACPAC file into the new database.
As mentioned in my comment above, the SQL Authentication provided was incorrect. This resulted in Azure to be unable to log in to the SQL server and connect in the third step.

How to import SQL database from file to Azure

How to load my SQL database created in MySQL Workbench on Azure cloud?
I created a database which consists of some tables - for now, there is now data in them, it's just a small script created by MySQL Workbench. I also created a database on Azure cloud, created login & password and when I want to use 'automated export' option (I have Storage account, I enter valid login with password) I have error:
'Could not find any bacpac files in the specified storage account.'
I tried google this phrase but I completely do not understand the idea behind these bacpac files and I do not know what to do with it. Can anyone describe me step-by-step how to put my database on Azure cloud?
I want to connect to this DB on Azure in the future because I would like to do a webapplication and android app which will use a remote DB available online.
Azure SQL Database is a custom SQL Server, so if you want to use MySQL you should create a Clear DB (which is a Microsoft partner that offers MySQL on azure). Other option, you can create a Virtual Machine and install by yourself a MySQL.
After that, you can import your tables / records.