sql server varbinary data output to azure blob

244 views Asked by At

I need output varbinary data (PDF) from sql server azure VM to blob. Is this possible? I have working code to export varbinary object to local drive, but I don't know how to export to azure blob storage. Specifically tricky is to replace @DocumentName with blob path.

            EXEC sp_OACreate 'ADODB.Stream', @ObjectToken OUTPUT
            EXEC sp_OASetProperty @ObjectToken, 'Type', 1
            EXEC sp_OAMethod @ObjectToken, 'Open'
            EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @Document     
            SET @DocumentName = 'I:\test\'filename'.pdf'
1

There are 1 answers

0
Bhavani On

I tried with below procedure to copy data from local drive to Azure blob storage: I created blob storage and created container.

enter image description here

I generated SAS token of then storage account:

enter image description here

I copied the container path and SAS token. I am using windows OS that's why I downloaded the azcopy module related to windows 64 bit and I copied that to C:\Windows\System32 and run below command in command prompt.

azcopy.exe

enter image description here

I used below command to copy data to azure blob storage:

azcopy.exe copy "<filepath>" "<containerpath>/<SAStoken>" --recursive

enter image description here

My file is successfully copied to azure blob storage:

enter image description here

It worked fine for me. you can check this once from your end.