I created one sample React app and pushed it to Github like below:-
I created one Azure Web app with Node version 18 and added these 2 Settings in Configuration, Refer below:-
Settings:-
SCM_DO_BUILD_DURING_DEPLOYMENT true
WEBSITE_WEBDEPLOY_USE_SCM true
went to Deployment > Deployment Center on left tab and selected above github repository and initiated the Github action workflow for Deployment like below:-
My github workflow:-
You can find my complete github workflow in this Link.
Code Reference
name: Build and deploy Node.js app to Azure Web App - siliconwebapp
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '18.x'
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: node-app
path: .
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: node-app
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'siliconwebapp'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_AB22E951505E4DC799565C7665CCC5D8 }}
package: .
Output:-
Note- Apart from adding the above Settings, When I deployed the App in different Web app even I received the same error code as yours, Refer below:-
Another Web app with name silicon-webapp where as the earlier one which was successful named siliconwebapp.
Package deployment using ZIP Deploy initiated.
[8](https://github.com/xxx/my-app1/actions/runs/xxx/jobs/xxx#step:3:9)Error: Failed to deploy web package to App Service.
[9](https://github.com/xxx/my-app1/actions/runs/xxx06070/jobs/xxx53864#step:3:10)Error: Deployment Failed, Error: Failed to deploy web package to App Service.
[10](https://github.com/xxxdesai/my-app1/actions/runs/xxx306070/jobs/9xxxx#step:3:11)Unauthorized (CODE: 401)
I deployed a new Web app siliconwebapp in another region and then added the above settings in Configuration and initiated the Github workflow from Deployment Center which was successful.
Reference:-
github - unable to deploy to azure web app services - Stack Overflow
You do not have permission to view this directory or page.
– Cormick