0

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.

K K Jangid
  • 19
  • 2
  • 401 unauthorized is likely to mean your publish-profile credentials are wrong. Try recreating it. see : https://learn.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#configure-the-github-secret – Rimaz Mohommed Jun 07 '23 at 02:41
  • i follow instruction but it gives an another error. – K K Jangid Jun 07 '23 at 03:18
  • i just did and app is deployed but when i visit [https://productlister.azurewebsites.net/](https://productlister.azurewebsites.net/) it shows an message `You do not have permission to view this directory or page.` – K K Jangid Jun 07 '23 at 07:17
  • Check the networking tab in your azure app service and ensure it is open to the internet (that there are no network access restrictions rules defined to disable public access) https://learn.microsoft.com/en-us/azure/app-service/app-service-ip-restrictions?tabs=azurecli#manage-access-restriction-rules-in-the-portal – Rimaz Mohommed Jun 07 '23 at 21:30

1 Answers1

0

I created one sample React app and pushed it to Github like below:-

enter image description here

enter image description here

I created one Azure Web app with Node version 18 and added these 2 Settings in Configuration, Refer below:-

enter image description here

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:-

enter image description here

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:-

enter image description here

enter image description here

enter image description here

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.

enter image description here

enter image description here

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

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11