1

We're running into an issue with the Azure Copy Files task on Azure DevOps. We've tried using version 3.* and 4.*. We do not use ampersands in our variables. It seems that the task is failing on the -containerSasToken variable, which we have no control over. It succesfully copies everything to blob, but when it starts copying to the VM the following errors occur:

2020-06-10T10:34:15.6572519Z ##[error]Execution of remote script job failed. ComputerName: '###', Message: 'Exception calling "Create" with "1" argument(s): "At line:12 char:297
+ ... n Sync Service - DEVELOP' -containerSasToken '?sv=2015-04-05&sr=c&sig ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

At line:12 char:302
+ ... c Service - DEVELOP' -containerSasToken '?sv=2015-04-05&sr=c&sig=IRc3 ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

At line:12 char:357
+ ... &sr=c&sig=IRc3wRXJkxsNXMvF%2FbklPRBhelc1qY2%2BDfCVKj2xBlk%3D&se=2020- ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

At line:12 char:385
+ ... FbklPRBhelc1qY2%2BDfCVKj2xBlk%3D&se=2020-06-10T14%3A34%3A08Z&sp=rwdl' ...
+                                                                 ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.

At line:12 char:8105033
+ ... tqBTFKkFalM7qofnRBLTVr0rsI6yuGNFCoXwvAAAAAAA=' -CleanTargetBeforeCopy
+                                                  ~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '."'
2020-06-10T10:34:15.7919052Z ##[section]Finishing: Copy files

It used to run without a problem on version 1.*. But we have to upgrade because we're going to use service principals now. Anyone have a clue what might be going wrong here?

Stephan Bisschop
  • 198
  • 1
  • 12
  • As far as I know , the `&` character is not supported in Powershell script. If the variable contains the character , it will show the same error. Have you tried to add **Double quotes** to the value (e.g. -sastoken "value")? [This ticket](https://stackoverflow.com/questions/54917110/how-do-i-include-ampersands-in-a-powershell-command-in-a-batch-file) may be helpful. – Kevin Lu-MSFT Jun 11 '20 at 06:54
  • @KevinLu-MSFT We're using the Azure Copy Files task. We do not set the sastoken variable ourselves. It's fetched by the task itself (I assume?) and somehow it doesn't escape the ampersands. – Stephan Bisschop Jun 11 '20 at 08:52
  • Yes. From the debug log, I notice that the sastoken is automatically generated and acquired. The `&` is contained. It seems that no option could control it. You may try to add the [azcopy arguments](https://learn.microsoft.com/en-us/azure/storage/common/storage-ref-azcopy-copy) to the `additionalArgumentsForVMCopy:` field in the task. – Kevin Lu-MSFT Jun 12 '20 at 09:46

0 Answers0