env:
AZURE_WEBAPP_PACKAGE_PATH: '.'
DOTNET_VERSION: '6.0.x'
on:
push:
branches: master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up dependency caching for faster builds
uses: actions/cache@v2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
- name: Login to Aure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: .net-app
- name: Deploy to Azure
uses: azure/CLI@v1
with:
azcliversion: latest
inlineScript: |
az deployment group create
-- name
-- resource-group
-- template-file Template/template.json
-- parameters storageAccountType=Standard_LRS
2
Answers
I had this a few weeks ago, something to with using "latest" was the issue.
Could you try replacing it with the below and see if the issue goes away?
I’m not sure what your issue is, but you are not logged in to Azure during the
deploy
phase of your work.You are logging in to Azure and then starting a new job. This is a new fresh container and it has no previous knowledge relating to your account.
I would move the Login part to the
deploy
step and see if that solves your issue.Apart from that, if the config you posted is the entire workflow you will run into an issue wit this part:
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
since the stepdeploy-to-webapp
is not in the config and as such there is no output to pull from.