Unable to upload to $web from GitHub actions

131 views Asked by At

I'm in the process of deploying our Flutter Web app to storage account within Azure, this particular storage account has had the Static website option enabled, doing so creates a $web container for me to deploy my site, uploading my files works perfectly fine and I'm able to see the website.

When I try to automate this with CICD is doesn't allow / can't see the $web container, if I switch out $web for a test container it works.

Does anyone know or even seen this issue before when trying to deploy a static website to the $web container, below is the part of the workflow file that does the upload:

 - name: Deploy to Azure Storage Static Website
      uses: azure/CLI@v1
      with:
        azcliversion: 2.0.72  # Use the desired Azure CLI version
        inlineScript: |
          az login --service-principal --username ${{ secrets.AZURE_CLIENT_ID }} --password ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
          az storage blob upload-batch --destination "\$web" --destination-path . --source build/web
      env:
          AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.AZURE_STORAGE_ACCOUNT_CONNECTION_STRING }}
1

There are 1 answers

0
SiddheshDesai On

According to This Document, the $web container is a reserved container name for static website hosting in Azure Storage. When you enable static website hosting, Azure Storage creates this container for you automatically. $web is the Default root container that is used to store static websites files. And,

According to this github comment by williexu forward slash is not supported in the blob root container. The files on the first level will be the only ones uploaded by upload-batch because blobs in subdirectories have names that include their path from the container. You need to utilize a non-root container if you want to upload files in batches recursively.

And This document - Use GitHub Actions to deploy a static site to Azure Storage | Microsoft Learn also uses -d '$web' without forward-slash. I referred the github action workflow and steps from this Document below:-

My github workflow:-

on: [push]

name: AzureLoginSample

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Login to Azure
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}
    - name: Upload to blob storage
      uses: azure/CLI@v1
      with:
        inlineScript: |
            az storage blob upload-batch --account-name valleystrg98  --auth-mode key -d '$web' -s .

Output:-

enter image description here