我正在使用Azure应用程序服务为我的ASP.NET项目提供共享层计划,这只允许1GB的临时文件。
我使用github actions将我的应用部署到azure,每次部署都会创建一个zip文件并将其存储在我的web应用的临时文件夹中。在几次部署后,我的临时存储配额已满,我无法再将其部署到我的应用,我收到了一个500错误。
解决方案是手动删除临时文件夹或重新启动应用程序(清除临时文件),但这无法实现CI/CD管道的目的。
是否可以在每次部署后自动清除临时文件夹文件?
编辑:我的github工作流
name: Build and deploy to Staging
env:
AZURE_WEBAPP_NAME: AppName # set this to the name of your Azure Web App
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '7.0.*' # set this to the .NET Core version to use
on:
push:
branches: [ "Staging" ]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up dependency caching for faster builds
uses: actions/cache@v3
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: dotnet publish
run: dotnet publish -c Release /p:PublishDir=${{env.DOTNET_ROOT}}/myapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
deploy:
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: 'Staging'
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 Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_STAGING }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
1条答案
按热度按时间4ioopgfo1#
我通过使用post deployment action hook和包含以下内容的.bat文件解决了我的问题: