0

I have an Azure Pipeline with a task using AzureStaticWebApp@0 to push code for a static web site from an Azure Storage account.

I've noticed that there is a growing number of unused files (mostly .js webpack chuncks), is there away of removing old files?

Maybe even deleting whole folders before pushing new code up?

The task looks a bit like this:

 - task: AzureStaticWebApp@0
              inputs:
                app_location: 'app/dist'
                api_location: 'api'
                output_location: 'dist'
                skip_app_build: true
user3067684
  • 936
  • 9
  • 18

3 Answers3

0

You can use the delete files task to clear out the contents of a folder. For example the below task would delete everything in the folder path specified

- task: DeleteFiles@1
  inputs:
    SourceFolder: 'C:/path/to/folder'
    Contents: '**/*'

Delete Files Task

DavidCox88
  • 813
  • 1
  • 10
  • Thanks for that, it does not delete the files from where they are beining served - Azure Blob Store as a web app – user3067684 Jul 18 '22 at 12:52
0

AzureStaticWebApp@0 remove ALL old files before uploading new

You could use Azure CLI task to invoke the az cli commands az storage blob delete-batch to clean old files before running the AzureStaticWebApp task. The sample task is as below:

- task: AzureCLI@2
  inputs:
    azureSubscription: 'Visual Studio Professional Subscription(xxxxxx)'
    scriptType: 'pscore'
    scriptLocation: 'inlineScript'
    inlineScript: 'az storage blob delete-batch -s images --account-name mystorage --source '$web' --if-unmodified-since $(date -d `"5 days ago`" ''+%Y-%m-%dT%H:%MZ'')'

You could also specify date to delete those old file which not modified a few days ago.

You could check the document az storage blob and the thread for some more details.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
0

So the answer was staring me in the face.

Use the same - task: AzureCLI@2 task to delete required files before uploading fresh build. enter link description here

user3067684
  • 936
  • 9
  • 18