I am trying to publish a .Net API to Azure app service. You can see the following workflow code,
name: Build and publish
on:
push:
branches:
- dev
- master
- publish-profile-path
pull_request:
branches:
- dev
- master
env:
AZURE_WEBAPP_PACKAGE_PATH: "./publish"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
- name: Restore
run: dotnet restore ./ABC.Solution/ABC.sln
- name: Build
run: dotnet build ./ABC.Solution/ABC.sln --configuration Release --no-restore
- name: Publish
run: dotnet publish ./ABC.Solution/ABC/ABC.csproj --configuration Release --no-build --property:PublishDir='./publish'
publish-dev:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/publish-profile-path'
environment: Development
steps:
- name: Deploy to Development
uses: azure/webapps-deploy@v2
with:
app-name: ABC-api-dev
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
package: "./publish"
This is the publish output,
I am getting the following error,
Any idea what the issue is? I tried to change the path but could not get it to work.
I tried with package: ./publish
in my workflow and got the same error:
AFAIK, this could be because /publish
folder is not available.
If you face any issues while deploying using GitHub actions, Configure deployment directly in web app:
Navigate to App Service=>Deployment center
, add GitHub as Source and fill the remaining details like select your GitHub organization and web app repository accordingly:
It generates GitHub workflow automatically to deploy the web app, check the workflow in GitHub=>your web app repository=> .github/workflows
.
I have deployed my .Net7 web api to Azure App Service using GitHub actions:
My workflow:
name: Build and deploy ASP.Net Core app to Azure Web App - <webappname>
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.x'
include-prerelease: true
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
deploy:
runs-on: windows-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: .net-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: '<webappname>'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_E5176XXXXXXXXXXX }}
package: .
Deployed Successfully: