Azcopy usinf sql sp

  • dallas13

    SSCertifiable

    Points: 7491

    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 2 months ago by  dallas13. Reason: formating
  • Phil Parkin

    SSC Guru

    Points: 243761

    If you execute whatever is in @Cmd directly from the command line, does it work?

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

  • dallas13

    SSCertifiable

    Points: 7491

    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.

  • Phil Parkin

    SSC Guru

    Points: 243761

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

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

  • dallas13

    SSCertifiable

    Points: 7491

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

  • Phil Parkin

    SSC Guru

    Points: 243761

    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 the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

  • Sue_H

    SSC Guru

    Points: 90286

    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

  • dallas13

    SSCertifiable

    Points: 7491

    Okay Sure. Thanks.

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

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