azureazure-devopsazure-static-web-app

AzureStaticWebApp push from artifacts error Failed to find a default file


When i try to build angular app using azure devops and deploy to azure static web app i'm receiving below error

`Failed to find a default file in the app artifacts folder (/). Valid default files: index.html,Index.html.

enter image description here`

here's the yaml code for the deployment section

# Deploy pipeline
trigger: none
stages:
 - stage: Deploy
   pool:
     vmImage: 'ubuntu-latest'
   jobs:
    - job: DeployFrontEnd
      steps:
       - task: DownloadPipelineArtifact@2
         inputs:
           buildType: 'specific'
           project: 'POMaster'
           definition: 'frontend'
           buildVersionToDownload: 'latest'
           allowPartiallySucceededBuilds: true
           allowFailedBuilds: true
           artifactName: 'app'
           targetPath: '$(Pipeline.Workspace)'
       - bash: cd $(Pipeline.Workspace)
       - bash: cd $(Pipeline.Workspace)/app
       - task: AzureStaticWebApp@0
         inputs:
           cwd: '$(Pipeline.Workspace)'
           app_location: '/'
           skip_app_build: true
           skip_api_build: true
           verbose: true
           output_location: 'dist/po-master-frontend'
         env:
           azure_static_web_apps_api_token: '$(deployment_token)'



What was the mistake i made. Please help!

Thanks

I tried by changing output_location to dist/po-master-frontend same as output location of angular.json,

nothing seems to work


Solution

  • Not sure how you published your artifact. The following is my configuration and yaml file for deploying static app. You can refer to it.

    1. Build and publish an artifact named app in one pipeline. The Artifact folder structure is as follows: enter image description here

    2. There is the yaml file used to deploy my static app in another pipeline.

      steps:
      - task: DownloadBuildArtifacts@1
        inputs:
          buildType: 'specific'
          project: '***'
          pipeline: '***'
          buildVersionToDownload: 'latest'
          downloadType: 'single'
          artifactName: 'app'
          downloadPath: '$(Pipeline.Workspace)'
      - task: AzureStaticWebApp@0
        inputs:
          azure_static_web_apps_api_token: $(token)
          cwd: '$(Pipeline.Workspace)/app/angular-basic'
          app_location: "/" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "" # Built app content directory - optional
    

    Then the deployment is successful. enter image description here