简体   繁体   中英

sql server varbinary data output to azure blob

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'

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

在此处输入图像描述

I generated SAS token of then storage account:

在此处输入图像描述

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

在此处输入图像描述

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

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

在此处输入图像描述

My file is successfully copied to azure blob storage:

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM