Azure Static Web App

Ken Netherland 21 Reputation points
2024-02-19T18:32:43.4766667+00:00

I accidently deployed sensitive files to my static web app. How do I delete them? I see "no" related storage account.

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,178 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Dan Rios 2,020 Reputation points MVP
    2024-02-19T22:11:30.3933333+00:00

    Under Settings > Environments you should see the deployment source? (Alternatively the overview page should show a recent deployment) That is where it’s deploying the files from.

    I don’t recall any FTP or backend Kudu style service on static web apps that you can directly access to delete the file manually so to speak.

    Therefore, you’ll like need to remove the sensitive file from the source repository via a pull request. This should trigger a new deployment to the web app and remove the sensitive file from the app.

    Let me know how you get on and if this was helpful in resolving the issue then please mark as accepted

    0 comments No comments

  2. Grmacjon-MSFT 19,301 Reputation points Moderator
    2024-02-26T20:26:21.05+00:00

    Hi @Ken Netherland adding to Dan's suggestion, here is another way to accomplish what you're trying to do via Azure CLI shared in this similar SO thread:

    You can use the Azure CLI task to invoke the az storage blob delete-batch command to clean old files before running the AzureStaticWebApp task. Here is a sample task:

    - 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'')'
    
    

    This command deletes old files that have not been modified for a few days. You can use the Delete Files task to clear out the contents of a folder. Here is an example:

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

    Please replace 'C:/path/to/folder' with the path to your folder Remember, these operations should be performed with caution to avoid deleting necessary files. Always make sure to have a backup of your important files. Let us know if you have further questions. -Grace

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.