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 5 years, 3 months ago by  dallas13. Reason: formating
  • If you execute whatever is in @Cmd directly from the command line, does it work?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • 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?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • 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!!

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • 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