Sai Krishna
Sai Krishna

Reputation: 85

AzureFileCopyV4 failed when uploading to Azure Storage Static Website "$web"

Using the AzureFileCopy@4 to copy the files from Source to $web container, it is throwing below error. In the documentation it is said that "If you are deploying to Azure Static Websites as a container in blob storage, you must use Version 2 or higher of the task in order to preserve the $web container name." but looks like it is still not working.

##[error]Container name '$web' is invalid. Valid names start and end with a lower case letter or a number and has in between a lower case letter, number or dash with no consecutive dashes and is 3 through 63 characters long.

Here is the code for the task:

- task: AzureFileCopy@4
        displayName: "AzureBlob File Copy"
        inputs:
          SourcePath: "$(System.DefaultWorkingDirectory)/src"
          azureSubscription: ${{ parameters.AzureConnection }}
          Destination: AzureBlob
          storage: $(TF_VAR_CDN_STORAGE_ACCOUNT_NAME)
          ContainerName: $(TF_VAR_BLOB_STORAGE_CONTAINER_NAME)

I would really appreciate if anyone can help me with this issue.

Thanks!

Upvotes: 1

Views: 566

Answers (1)

chad701
chad701

Reputation: 11

I was able to get it working by creating a variable with the $web container. This will prevent it from being read as a token.

task: AzureCLI@2
  displayName: Azure CLI File Copy
  inputs:
    azureSubscription: {subscription}
    scriptType: ps
    scriptLocation: inlineScript
    inlineScript: |
      $Container = '$web'
      az storage copy -s $(System.ArtifactsDirectory)/{your files}/*.* --destination-account-name {accountname} --destination-container $Container --recursive

Upvotes: 1

Related Questions