使用GitHub Actions和Azure CLI部署.NET 6 Web API时出现‘not enough values to unpack’错误求助
GitHub Actions和Azure CLI部署.NET 6 Web API时出现‘not enough values to unpack’错误求助
您好!我在尝试使用GitHub Actions部署.NET 6 Web API的过程中遇到了not enough values to unpack错误,目前还没找到问题根源。以下是我的相关配置信息,麻烦各位帮忙排查一下,如果需要更多细节我随时补充,非常感谢!
我的GitHub Action配置
name: Build ASP.NET code (Web App for WebAPI) on: workflow_dispatch: inputs: environment: description: 'Environment' type: environment required: true app-configuration: type: choice description: Select App Settings File default: 'appsettings.Development.json' options: - appsettings.Development.json - appsettings.SIT.json required: true env: AZURE_WEBAPP_WEBAPI_NAME: ${{ secrets.AZURE_WEBAPP_WEBAPI_NAME }} CERT: ${{ secrets.CERT }} WORKING_DIRECTORY: src/Test.WebApi BUILD_CONFIGURATION: ${{ inputs.build-configuration }} #NUGET_VERSION: 4.4.1 CLIENT_ID: ${{ secrets.CLIENT_ID }} TENANT_ID: ${{ secrets.TENANT_ID }} RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }} JSON_PATH: ${{ inputs.app-configuration }} jobs: build: runs-on: windows-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Navigate to Workspace run: cd ${{ env.WORKING_DIRECTORY }} - name: Create Build Directory run: mkdir _build - name: Build Project run: dotnet build ${{ env.WORKING_DIRECTORY }}/Test.WebApi.sln --property:OutputPath="../_build" --configuration Release - name: Test Project run: dotnet test ${{ env.WORKING_DIRECTORY }}/Test.WebApi.Tests --no-restore --verbosity normal - name: Upload artifact uses: actions/upload-artifact@v1.0.0 with: name: ASP-app path: "${{ env.WORKING_DIRECTORY }}/_build" deploy-to-staging-slot: runs-on: ubuntu-latest needs: build environment: ${{ inputs.environment }} steps: - name: Checkout uses: actions/checkout@v3 # Logs in with below Azure credentials - name: login to az shell: bash run: | echo "$CERT" > sfh-mvc-cert.pem az login --service-principal -u $CLIENT_ID -p sfh-mvc-cert.pem --tenant $TENANT_ID - name: Download artifact from build job uses: actions/download-artifact@v2 with: name: ASP-app path: download/ASP-app - name: test run: | cd download/ASP-app echo "listing ASP-app" ls - name: Deploy to Azure Web App id: deploy-to-webapp uses: azure/webapps-deploy@v2.2.9 with: app-name: ${{ env.AZURE_WEBAPP_WEBAPI_NAME }} package: download/ASP-app slot-name: staging - name: Deafult WebApp Configuration from appsettings.json uses: azure/CLI@v1 with: azcliversion: 2.42.0 inlineScript: | az webapp config appsettings set -g "${{ env.RESOURCE_GROUP }}" -n '${{ env.AZURE_WEBAPP_WEBAPI_NAME }}' --settings "@Test.WebApi/Test.WebApi/appsettings.json" -s staging - name: WebApp Configuration uses: azure/CLI@v1 with: azcliversion: 2.42.0 inlineScript: | az webapp config appsettings set -g "${{ env.RESOURCE_GROUP }}" -n '${{ env.AZURE_WEBAPP_WEBAPI_NAME }}' --settings "@Test.WebApi/Test.WebApi/${{ env.JSON_PATH }}" -s staging deploy-to-production-slot: runs-on: ubuntu-latest needs: deploy-to-staging-slot environment: ${{ inputs.environment }} steps: - name: Checkout uses: actions/checkout@v3 - name: login to az shell: bash run: | echo "$CERT" > sfh-mvc-cert.pem az login --service-principal -u $CLIENT_ID -p sfh-mvc-cert.pem --tenant $TENANT_ID - name: 'Swap Slots: ${{ env.AZURE_WEBAPP_WEBAPI_NAME }}' uses: Azure/cli@v1.0.0 with: inlineScript: az webapp deployment slot swap --resource-group ${{ env.RESOURCE_GROUP }} --name ${{ env.AZURE_WEBAPP_WEBAPI_NAME }} --slot staging --target-slot production - name: Deafult WebApp Configuration from appsettings.json uses: azure/CLI@v1 with: azcliversion: 2.42.0 inlineScript: | az webapp config appsettings set -g "${{ env.RESOURCE_GROUP }}" -n '${{ env.AZURE_WEBAPP_WEBAPI_NAME }}' --settings "@Test.WebApi/Test.WebApi/appsettings.json" - name: WebApp Configuration uses: azure/CLI@v1 with: azcliversion: 2.42.0 inlineScript: | az webapp config appsettings set -g ${{ env.RESOURCE_GROUP }} -n '${{ env.AZURE_WEBAPP_WEBAPI_NAME }}' --settings "@Test.WebApi/Test.WebApi/${{ env.JSON_PATH }}"
我的appsettings.json配置
{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "ServiceBusConfigOption": { "ConnectionString": "KeyVaultSecret-ServiceBusConnectionString", "TopicsEmailTemplate": "EmailTemplates", "TopicUserSetting": "UserSettings" }, "JwtConfigOption": { "Secret": "KeyVaultSecret-ApiJwtSecret", "Issuer": "KeyVaultSecret-ApiJwtIssuer", "Audience": "KeyVaultSecret-ApiJwtAudience", "ClientId": "KeyVaultSecret-ApiJwtClientId", "ClientSecret": "KeyVaultSecret-ApiJwtClientSecret", "ExpiryMinutes": 20 }, "StorageConfigOption": { "ConnectionString": "KeyVaultSecret-AzureWebJobStorage" }, "RepositoryOptions": { "CosmosConnectionString": "KeyVaultSecret-ConnectionString", "DatabaseId": "TestDb", "OptimizeBandwidth": true, "ContainerPerItemType": true, "AllowBulkExecution": true, "SerializationOptions": { "IgnoreNullValues": true, "PropertyNamingPolicy": "Default" } }, "KeyVaultConfigOption": { "Url": "{keyvaultUrl}.vault.azure.net", "RefreshIntervalInMinutes": 45, "SecretPrefix": "KeyVaultSecret" } }
备注:内容来源于stack exchange,提问作者Rakesh Kumar
相关产品推荐
相关产品推荐

