> “Failed to find a default file in the app artifacts folder (wwwroot). Valid default files: index.html, Index.html.”
I got the same error while deploying a sample Blazor WebAssembly application to an Azure Static Web App.
To resolve the issue, I updated the `app_location` and `output_location` in my GitHub Workflow file to match my project structure.
```
app_location: "src/Blazor.client/Blazor.client"
api_location: "src/Blazor.HttpApi/Blazor.HttpApi"
output_location: "src/Blazor.client/Blazor.client/wwwroot"
```
![enter image description here](https://i.imgur.com/2LYi7pS.png)
**GitHub Workflow File**:
```yml
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_SAND_0A1C20F0F }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
app_location: "src/Blazor.client/Blazor.client"
api_location: "src/Blazor.HttpApi/Blazor.HttpApi"
output_location: "wwwroot"
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_SAND_0A1C20F0F }}
action: "close"
```
**Azure Output**:
![enter image description here](https://i.imgur.com/imF3Kcv.png)
I created a sample Blazor web app, deployed it successfully to Azure Static Web Apps, and can view the scripts after deployment.
- Ensure the `index.html` file is generated and placed in the correct directory (i.e. `wwwroot`).
My **gulpfile.js:**
```js
const gulp = require("gulp");
const esbuild = require("esbuild");
const paths = {
entries: ["./Components/Canvas2D/Canvas2d.ts"],
output: "./wwwroot",
};
gulp.task("default", async function () {
try {
await esbuild.build({
entryPoints: paths.entries,
outdir: paths.output,
bundle: true,
target: "es2015",
format: "esm",
sourcemap: true,
minify: true,
});
console.log("Build completed successfully");
gulp.src('index.html')
.pipe(gulp.dest(paths.output));
console.log("index.html copied to wwwroot");
} catch (error) {
console.error("Build failed:", error);
process.exit(1);
}
});
```
**package.json:**
```
{
"name": "blazorappwithgulp",
"version": "1.0.0",
"main": "gulpfile.js",
"scripts": {
"build": "gulp default",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "Blazor WebAssembly project with Gulp for TypeScript to JavaScript compilation",
"devDependencies": {
"gulp": "^5.0.0",
"gulp-esbuild": "^0.14.0"
},
"dependencies": {
"esbuild-wasm": "^0.24.2"
}
}
```
- Make sure you configure correct `app_location` and `output_location`.
**Workflow file:**
```
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Clean npm cache and install dependencies
run: |
rm -rf node_modules
npm ci # Ensures fresh installation of dependencies
- name: Install gulp globally
run: npm install -g gulp-cli
- name: Check Gulp version
run: |
npx gulp --version
- name: Run gulp build
run: |
npx gulp default
- name: Deploy to Azure Static Web Apps
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_RED_WATER_081F97E0F }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/"
output_location: "wwwroot"
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_RED_WATER_081F97E0F }}
action: "close"
```
I've successfully deployed the app to Azure Static Web Apps via GitHub Actions.
![enter image description here](https://i.imgur.com/JdoAef3.png)
Now I can view the scripts after the deployment.
![enter image description here](https://i.imgur.com/PBMbeP1.png)