Reputation: 79
Hi I'm trying to deploy my react app using Azure Web app service using github action as deployment provider. build process have done but deploy step shows error at the end. here is error sample:
Run azure/webapps-deploy@v2
with:
app-name: productlister
slot-name: Production
publish-profile: ***
package: .
Package deployment using ZIP Deploy initiated.
Error: Failed to deploy web package to App Service.
Error: Deployment Failed, Error: Failed to deploy web package to App Service.
Unauthorized (CODE: 401)
App Service Application URL: [https://productlister.azurewebsites.net](https://productlister.azurewebsites.net)
i used github action yml file as workflow. i looking for solution of this error. im not aware about error.
Upvotes: 6
Views: 12309
Reputation: 39
For me the solution was to enable Basic Auth found at
Your App Service > Configuration (on left pane) > SCM Basic Auth > On
Upvotes: 3
Reputation: 122
I had the same problem and i found a good way to analyze the problem:
If you navigate to your "Deployment Center" in Azure, you could download the publish profile. This could help you to check what went wrong. (You could also just import the publish profiles, this should definitely work.)
Upvotes: 3
Reputation: 8187
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
Upvotes: 3