Azcopy usinf sql sp

  • Hello Experts,

    I am working on SP that sends my csv file from on prem machine to Azure blob container. I am using lastest Azcopy v10.

    DECLARE @Program varchar(200) = '"C:\AzCopy.exe"'
    DECLARE @Source varchar(max) = 'E:\Backup\abc.txt'

    DECLARE @Destination varchar(max) = 'https://myaccount.blob.core.windows.net/'
    DECLARE @DestKey varchar(max) = 'secret key'
    DECLARE @Options varchar(max) = '/S /XO /XN /Y /V:E:\Backup\AzCopy-Log.txt /Z:'

    DECLARE @Cmd varchar(5000)
    SELECT @Cmd = @Program +' /Source:'+ @Source +' /Dest:'+ @Destination +' /DestKey:'+ @DestKey +' '+ @Options
    PRINT @cmd

    EXECUTE master..xp_cmdshell @Cmd

    When I run this code, I get below error

    Error: unknown command "/Source:E:\\Backup\\abc.txt" for "azcopy"Run 'azcopy --help' for usage.NULLunknown command "/Source:E:\\Backup\\abc.txt" for "azcopy"NULL

    • This topic was modified 4 years, 7 months ago by  dallas13. Reason: formating
  • If you execute whatever is in @Cmd directly from the command line, does it work?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Nope, its the same error there too. Trying to fix it but not sure why its not working. if anyone has worked on similar and tell if the syntax is correct or what is the issue here? Thanks a lot.

  • This command won't work unless you have already authenticated with Azure somehow ... have you done that elsewhere in your code?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Yes Phil. Authentication part is not an issue at all. It works. Thanks for your help.

  • dallas13 wrote:

    Yes Phil. Authentication part is not an issue at all. It works. Thanks for your help.

    Np. And lucky you. The hardest part of everything I do in Azure seems to be authentication!!

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • That Unknown Command error seemed like it started popping up a lot on version 10. Maybe try 8.1 or whatever it was previously...I think 8.1.

    Sue

  • Okay Sure. Thanks.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply