0

I am trying to deploy my first Azure Static Web App from Azure DevOps using a self-hosted agent on my local Windows machine. The agent is set up and appears online in the Azure DevOps settings. However, I am encountering an issue with the AzureStaticWebApp task in my pipeline.

Here is the YAML configuration of the pipeline:

name: Azure Static Web Apps CI/CD

pr:
  branches:
    include:
      - master
trigger:
  branches:
    include:
      - master

jobs:
- job: build_and_deploy_job
  displayName: Build and Deploy Job
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    name: Local Agent Pool
  variables:
  - group: Azure-Static-Web-Apps-victorious-beach-0d42cb803-variable-group
  steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_VICTORIOUS_BEACH_0D42CB803)
      app_location: "/"
      api_location: ""
      output_location: "build"
      skip_api_build: true

Now the issue: When I run the pipeline, the AzureStaticWebApp task fails with the following error message:

2024-10-04T14:42:16.5040695Z [command]C:\WINDOWS\system32\bash.exe C:\agent\_work\_tasks\AzureStaticWebApp_18aad896-e191-4720-88d6-8ced4806941a\0.246.1\launch-docker.sh
2024-10-04T14:42:22.3067301Z /bin/bash: C:agent_work_tasksAzureStaticWebApp_18aad896-e191-4720-88d6-8ced4806941a0.246.1launch-docker.sh: No such file or directory
2024-10-04T14:42:22.3142262Z 
2024-10-04T14:42:22.3238448Z ##[error]Error: The process 'C:\WINDOWS\system32\bash.exe' failed with exit code 127
2024-10-04T14:42:22.3285032Z ##[section]Finishing: AzureStaticWebApp

I think the problem appears to be related to how paths are being handled. The command that fails seems to use a Windows-style path, but the Bash environment expects a Linux-style path. I believe it should look something like this:

C:\WINDOWS\system32\bash.exe mnt\c\agent\_work\_tasks\AzureStaticWebApp_18aad896-e191-4720-88d6-8ced4806941a\0.246.1\launch-docker.sh

But I have no idea to change it, nor any idea if I should change it somewhere or if my configuration is incorrect... Any help?

WSL is correctly installed and docker is also accessible within the WSL environment.

2 Answers 2

4

The AzureStaticWebApp@0 task can only run on Linux agents. It is not available for Windows agents.

enter image description here

To run this task, you can:

  1. Use the Microsoft-hosted agents which is on Linux VM, such as ubuntu-24.04, ubuntu-22.04 (ubuntu-latest) or ubuntu-20.04.

  2. Install self-hosted agents on yourself local Linux machines or Linux VM.


Sign up to request clarification or add additional context in comments.

1 Comment

As clarified in the answer, you need to used Linux agents to run the AzureStaticWebApp@0 task. Have tried as this, and does it work for you? @EmileCaron
0

The correct answer is already given by Bright Ran-MSFT. I only want to say that you can use a workaround if you don't want to make use of an Linux agent.

You can also make use of a storage account for static websites. I am not sure if that will fit your needs, but if it does, than you might consider to use the option below.

How I deploy a static website is: I am using an ARM template for a storage account.

    - task: AzureResourceManagerTemplateDeployment@3
  displayName: "Create Static Website Storage Account"
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: ${{ parameters['ServiceConnection']}}
    subscriptionId: $(SubscriptionID)
    action: 'Create Or Update Resource Group'
    resourceGroupName: $(ResourceGroup)
    location: 'West Europe'
    templateLocation: 'Linked artifact'
    csmFile: '$(Pipeline.Workspace)/drop/armtemplates/staticwebapp_deployment.json'
    csmParametersFile: '$(Pipeline.Workspace)/drop/armtemplates/staticwebapp_parameters.json'
    deploymentMode: 'Incremental'
    overrideParameters: '-SubscriptionName $(subname) -VersionToDeploy $(VersionToDeploy) -StorageAccountNameStaticWebApp $(StaticWebAppName)'
  continueOnError: false

The second task is a AzurePowershell task which I use to enable static website.

    - task: AzurePowerShell@5
  displayName: "Enable Static Website"
  inputs:
    azureSubscription: ${{ parameters['ServiceConnection']}}
    ScriptType: 'FilePath'
    ScriptPath: '$(Pipeline.Workspace)/drop/Scripts/EnableStaticWebSite.ps1'
    ScriptArguments: '-ResourceGroup $(ResourceGroup) -StorageAccountNameStaticWebApp $(StorageAccountNameStaticWebApp)'
    azurePowerShellVersion: 'LatestVersion'
  continueOnError: false

Maybe this will help you to deploy it as an workaround. I have not included the arm template and the script itself, but if you need I can paste it here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.