Permission Issue on Bulk Insert in Azure SQL Server - azure

User is getting below error while running bulk insert command in Azure SQL Server. I am using Azure SQL Server and not SQL Sever. Most of the commands related to Bulk Insert grant permission is not working in Azure SQL Server.
Error
You do not have permission to use the bulk load statement.
Commands Tried in Azure SQL Server to Add User
EXEC sp_addrolemember 'db_ddladmin', 'testuser';
ALTER SERVER ROLE [bulkadmin] ADD MEMBER testuser
GRANT ADMINISTER BULK OPERATIONS TO testuser
Error
Msg 40520, Level 16, State 1, Line 5
Securable class 'server' not supported in this version of SQL Server.
Your help is highly appreciated.

In Azure SQL Database, grant ADMINISTER DATABASE BULK OPERATIONS to the principal in the context of the desire database:
GRANT ADMINISTER DATABASE BULK OPERATIONS TO testuser;
The user will also need INSERT permissions on the target table. These Azure SQL Database permissions are detailed in the BULK INSERT documentation under the permissions section.

On Azure it works on tables in the database in question only. It does not work on temp tables. So if you are bulk loading in parallel and want to use temp tables, you are in a corner.

GRANT CONTROL to testuser
nothing else is needed, just this to be executed in content DB (not master)
full steps
in Master
CREATE LOGIN login1 WITH password='1231!#ASDF!a';
in content DB
CREATE USER user1 FROM LOGIN login1;
GRANT CONTROL to user1; --(this is for bulk to work)

Related

Azure SQL database with MFA login to connect from Azure ADF

I have an Azure SQL server and database which have MFA login and I am the admin. But when I try to establish a connection via a new linked service from ADF to this database using System Managed Identity option, it throws error -
"Cannot connect to SQL Database. Please contact SQL server team for further support. Server: 'Server details', Database: 'database name', User: ''. Check the linked service configuration is correct, and make sure the SQL Database firewall allows the integration runtime to access.
I have already given contributor role access to ADF in SQL database using system managed Identity. Also, I have tried to access this database using Autoresolve runtime and azure runtime. But still the error is coming.
It sounds like you are missing the user creation and role assignment within the SQL database:
Connect to the database with your account and create an account for the data factory:
CREATE USER [<datafactory-name>] FROM EXTERNAL PROVIDER;
Then grant it the required role for your task:
ALTER ROLE [<roleName>] ADD MEMBER [<datafactory-name>]
Some available role names are:
db_accessadmin
db_backupoperator
db_datareader
db_datawriter
db_ddladmin
db_denydatareader
db_denydatawriter
db_owner
db_securityadmin
public
I created Azure SQL database in portal and created linked service in azure data factory with managed identity authentication I got below error:
I followed below procedure to resolve this:
I turned on the managed identity of data factory
I set admin for azure SQL database:
Login with Admin to sql database Create User username as data factory name using below code:
CREATE USER [DATAFACTORY NAME] FROM eXTERNAL PROVIDER
Added rules to the user using below code:
ALTER ROLE db_datareader ADD MEMBER [DATA FACTORY NAME];
I tested linked service again, tested successfully
It worked for me, once check from your end.

Link Azure SQL Database to Data Factory using managed identity

I have been trying to use Managed Identity to connect to Azure SQL Database from Azure Data factory.
Steps are as follow:
Created a Linked Service and selected Managed Identity as the Authentication Type
On SQL Server, added Managed Identity created for Azure Data Factory as Active Directory Admin
The above steps let me do all data operations on the database. Actually that is the problem. I want to restrict the privileges given to Azure Data Factory on my SQL database.
First, let me know whether I have followed the correct steps to set up the managed identity. Then, how to limit privileges because I don't want data factory to do any DDL on SQL database.
As Raunak comments,you should change the role to db_datareader.
In you sql database,run this sql:
CREATE USER [your Data Factory name] FROM EXTERNAL PROVIDER;
and this sql:
ALTER ROLE db_datareader ADD MEMBER [your Data Factory name];
You can find '[your Data Factory name]' here
Then you do any DDL operation in Data Factory,you will the error like this:
"errorCode": "2200",
"message": "ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed. Please search error to get more details.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Data.SqlClient.SqlException,Message=The INSERT permission was denied on the object
Update:
1.Search for and select SQL server in azure portal
2.select you and save as admin
3.click the button and run two sql in sql database.
More details,you can refer to this documentation.

Has anyone been able to successfully execute SET RESULT_SET_CACHING on Azure SQL Warehouse?

I currently have an Azure SQL data warehouse and I'd like to enable caching so that intensive queries run faster in the database with the following code:
ALTER DATABASE [myDB]
SET RESULT_SET_CACHING ON;
However, no matter how I try to run this query I get the following error:
Msg 5058, Level 16, State 12, Line 3
Option 'RESULT_SET_CACHING' cannot be set in database 'myDB'.
I am running the query based on Azure's documentation here: https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-set-options?view=azure-sqldw-latest
I have tried running this query both in the master database and in the underlying one called myDB. I have also tried using commands such as:
USE master
GO
With no avail. Has anyone had success in enabling caching on Azure? Please let me know!
Screenshot of error and command below:
https://i.stack.imgur.com/mEJIy.png
I tested and this command works well in my ADW dwleon, see the bellow screenshot:
Please make sure:
Login you Azure SQL data warehouse with SQL server Admin account.
Run this command in master db
Summary of the document:
To set the RESULT_SET_CACHING option, a user needs server-level
principal login (the one created by the provisioning process) or be a
member of the dbmanager database role.
Enable result set caching for a database:
--Run this command when connecting to the MASTER database
ALTER DATABASE [database_name]
SET RESULT_SET_CACHING ON;
Hope this helps.

Recieving CREATE USER error when attempt to import BACPAC from blob storage to ssms

I am attempting to backup and restore a database located in Azure SQL database via Azure blob storage. To do this I have run Export Data-Tier Application... on the selected database and successfully stored it in a blob container as a BACPAC file. Now I am trying to do the reverse and Import Data-Tier Application... to check the backup process functions correctly, however I receive the following error during the process:
Could not import package.
Error SQL72014: .Net SqlClient Data Provider: Msg 15063, Level 16,
State 1, Line 1 The login already has an account under a different
user name.
Error SQL72045: Script executation error. The executed script: CREATE
USER [username] FOR LOGIN [username];
(Microsoft.SqlServer.Dac)
This results in the Importing database, Importing package schema and data into database and Updating database operations failing, and the creation of an empty database.
I'm unsure where the login or creating a user becomes relevant in importing the database, do you know why this error is occuring?
Run this query on master. It will give you a list of logins that exist at the server level.
SELECT A.name as userName, B.name as login, B.Type_desc, default_database_name, B.*
FROM sys.sysusers A
FULL OUTER JOIN sys.sql_logins B
ON A.sid = B.sid
WHERE islogin = 1 and A.sid is not null
Run this on the database you want to export as bacpac for later import it on your SQL Server instance:
SELECT DB_NAME(DB_ID()) as DatabaseName, * FROM sys.sysusers
You need to remove logins on the database that you see exist at the server level (on the master database). After that try to export the database as bacpac and import it to your SQL Server instance.
If you don't want to remove those logins/users on your current SQL Azure database, copy it as a new Azure SQL, remove logins, export it, and then drop the copied database when finish.
If you want to restore the bacpac in Azure, use the Import option on the portal instead of SSMS.
Download the latest SSMS for the best user experience.

Create Database Permission on Azure SQL DW

Im trying to assign Create Database Permission to one of User Account in Azure SQL DW but its giving error while trying to execute it.
Tsql:
grant alter any database to [test_user1]
Error:
Securable class 'server' not supported in this version of SQL Server.
Please let me know if this permission (Create Database) can be used in Azure SQL DW

Resources