提问人:Francisco 提问时间:11/3/2023 更新时间:11/3/2023 访问量:39
部署时具有 github var 环境的 .NET 7 appsettings.json 无法正常工作
.NET 7 appsettings.json with github var environment not working properly when deployed
问:
使用 GitHub 机密值部署我的应用程序时,我的应用程序无法再进行身份验证,即使由于某种原因这些值看起来相同,它也无法正常工作。
name: Build and deploy .NET Core application to Web App nnnnnnn-dev with API Management Service nnnnnnn-nnnnnnn
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
environment:
description: 'Environment to run tests against'
type: environment
required: true
push:
branches:
- master
- release
env:
AZURE_WEBAPP_PATH: 'src\nnnnnnn\publish'
AZURE_WEBAPP_PACKAGE_PATH: src\nnnnnnn.API\publish
SWASHBUCLE_ASPNET_CORE_CLI_PACKAGE_VERSION: 5.6.3
SWASHBUCKLE_DOTNET_CORE_VERSION: 3.1.x
API_IMPORT_SPECIFICATION_PATH: src\nnnnnnn.API\publish\swagger.json
API_IMPORT_VERSION: v1
DOTNET_CORE_VERSION: 7.0.x
WORKING_DIRECTORY: src\nnnnnnn.API
jobs:
build:
runs-on: windows-latest
environment:
name: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Setup SwashBuckle .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.SWASHBUCKLE_DOTNET_CORE_VERSION }}
- name: Restore
run: dotnet restore ${{ env.WORKING_DIRECTORY }}
- name: Build
run: dotnet build ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Test
run: dotnet test ${{ env.WORKING_DIRECTORY }} --no-build
- name: Publish
run: dotnet publish ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-build --output ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Install Swashbuckle CLI .NET Global Tool
run: dotnet tool install --global Swashbuckle.AspNetCore.Cli --version ${{ env.SWASHBUCLE_ASPNET_CORE_CLI_PACKAGE_VERSION }}
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Publish Artifacts
uses: actions/[email protected]
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
deploy:
runs-on: windows-latest
permissions:
packages: write
deployments: write
contents: read
actions: read
environment:
name: ${{ github.ref_name }}
needs: build
steps:
- uses: actions/checkout@v2
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Login via Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: SETUP .NET CORE
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: dotnet build + publish
run: |
dotnet build --configuration release
dotnet publish -c Release -o ${{ env.AZURE_WEBAPP_PATH }}
#substitute production appsettings entries to appsettings json file
- name: App Settings Variable Substitution
uses: microsoft/variable-substitution@v1
with:
files: '**/appsettings.json'
env:
#ROLES
MyConfiguration.Roles.Administrator: ${{ secrets.ROL_ADMINISTRATOR }}
MyConfiguration.Roles.ServiceProvider: ${{ secrets.ROL_SERVICE_PROVIDER }}
MyConfiguration.Roles.User: ${{ secrets.ROL_USER }}
#JWT
MyConfiguration.JWT.key: ${{ secrets.JWT_KEY }}
MyConfiguration.JWT.ValidAudience: ${{ env.JWT_VALID_AUDIENCE }}
MyConfiguration.JWT.ValidIssuer: ${{ env.JWT_VALID_ISSUER }}
MyConfiguration.JWT.TokenValidityInDays: ${{ env.JWT_TOKEN_VALIDITY_IN_DAYS }}
MyConfiguration.JWT.RefreshTokenValidityInDays: ${{ env.JWT_REFRESH_TOKEN_VALIDITY_IN_DAYS }}
- name: Deploy to App Services
uses: azure/webapps-deploy@v2
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PATH }}
- name: logout
run: >
az logout
yml 部署没有问题,但变量无法识别
我尝试了不同的方法
引号或双引号,并始终成功部署
答: 暂无答案
评论