{"meta":{"title":"Bereitstellen in Azure Static Web Apps","intro":"Erfahren Sie, wie Sie eine Web-App als Teil Ihrer CD-Workflows (Continuous Deployment) für Azure Static Web App bereitstellen.","product":"GitHub Actions","breadcrumbs":[{"href":"/de/actions","title":"GitHub Actions"},{"href":"/de/actions/how-tos","title":"Anleitungen"},{"href":"/de/actions/how-tos/deploy","title":"Bereitstellen"},{"href":"/de/actions/how-tos/deploy/deploy-to-third-party-platforms","title":"Bereitstellen auf Drittanbieterplattformen"},{"href":"/de/actions/how-tos/deploy/deploy-to-third-party-platforms/azure-static-web-app","title":"Azure Static Web App"}],"documentType":"article"},"body":"# Bereitstellen in Azure Static Web Apps\n\nErfahren Sie, wie Sie eine Web-App als Teil Ihrer CD-Workflows (Continuous Deployment) für Azure Static Web App bereitstellen.\n\n## Voraussetzungen\n\nBevor du deinen GitHub Actions-Workflow erstellst, musst du die folgenden Einrichtungsschritte ausführen:\n\n1. Erstellen Sie eine Azure Static Web App mit der Option \"Other\" für die Bereitstellungsquelle. Weitere Informationen finden Sie unter [Quickstart: Erstellen Ihrer ersten statischen Website im Azure Portal](https://docs.microsoft.com/azure/static-web-apps/get-started-portal) in der Azure Dokumentation.\n\n1. Erstelle ein Geheimnis namens `AZURE_STATIC_WEB_APPS_API_TOKEN` mit dem Wert des Bereitstellungstokens deiner statischen Web-App. Weitere Informationen zum Auffinden Ihres Bereitstellungstokens finden Sie in [Reset-Bereitstellungstoken in Azure Static Web Apps](https://docs.microsoft.com/azure/static-web-apps/deployment-token-management) in der Azure Dokumentation.\n\n## Erstellen des Workflows\n\nNachdem die Voraussetzungen erfüllt sind, kannst du mit dem Erstellen des Workflows fortfahren.\n\nIm folgenden Beispielworkflow wird veranschaulicht, wie Eine Azure statische Web-App erstellt und bereitgestellt wird, wenn ein Push an die `main` Branch erfolgt oder wenn eine Pullanforderung für `main` geöffnet, synchronisiert oder erneut geöffnet wird. Der Workflow beseitigt auch die entsprechende Pre-Production-Bereitstellung, wenn ein an `main` gerichteter Pull Request geschlossen wird.\n\nÄndere unter dem Workflowschlüssel `env` die folgenden Werte:\n*               `APP_LOCATION` zum Speicherort deines Clientcodes.\n*               `API_LOCATION` zum Speicherort deines API-Quellcodes. Wenn `API_LOCATION` nicht relevant ist, kannst du die Variable löschen und ebenso die Zeilen, in denen sie verwendet wird.\n*               `OUTPUT_LOCATION` zum Speicherort deiner Clientcode-Build-Ausgabe.\n\nWeitere Informationen zu diesen Werten finden Sie in der Azure dokumentation unter [Build-Konfiguration für Azure Static Web Apps](https://docs.microsoft.com/azure/static-web-apps/build-configuration?tabs=github-actions).\n\n```yaml copy\n# Dieser Workflow verwendet Aktionen, die nicht von GitHub zertifiziert sind.\n# Sie werden von einem Drittanbieter bereitgestellt und unterliegen\n# separaten Nutzungsbedingungen, Datenschutzbestimmungen und Support\n# Onlinedokumentation.\n\n# GitHub empfiehlt, Aktionen an einen Commit-SHA anzuheften.\n# Um eine neuere Version zu erhalten, musst du den SHA aktualisieren.\n# Du kannst auch auf ein Tag oder einen Branch verweisen, aber die Aktion kann sich ohne Vorwarnung ändern.\n\nname: Deploy web app to Azure Static Web Apps\n\nenv:\n  APP_LOCATION: \"/\" # location of your client code\n  API_LOCATION: \"api\" # location of your api source code - optional\n  OUTPUT_LOCATION: \"build\" # location of client code build output\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    types: [opened, synchronize, reopened, closed]\n    branches:\n      - main\n\npermissions:\n  issues: write\n  contents: read\n  pull-requests: write\n\njobs:\n  build_and_deploy:\n    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')\n    runs-on: ubuntu-latest\n    name: Build and Deploy\n    steps:\n      - uses: actions/checkout@v6\n        with:\n          submodules: true\n      - name: Build And Deploy\n        uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9\n        with:\n          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}\n          repo_token: ${{ secrets.GITHUB_TOKEN }}\n          action: \"upload\"\n          app_location: ${{ env.APP_LOCATION }}\n          api_location: ${{ env.API_LOCATION }}\n          output_location: ${{ env.OUTPUT_LOCATION }}\n\n  close_pull_request:\n    if: github.event_name == 'pull_request' && github.event.action == 'closed'\n    runs-on: ubuntu-latest\n    name: Close Pull Request\n    steps:\n      - name: Close Pull Request\n        uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9\n        with:\n          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}\n          action: \"close\"\n```\n\n## Weitere Informationen\n\n* Die ursprüngliche Workflowvorlage finden Sie unter [`azure-staticwebapp.yml`](https://github.com/actions/starter-workflows/blob/main/deployments/azure-staticwebapp.yml) im GitHub Actions-Repository `starter-workflows`.\n* Die Aktion zum Bereitstellen der Webanwendung ist die offizielle Azure-Aktion [`Azure/static-web-apps-deploy`](https://github.com/Azure/static-web-apps-deploy).\n* Weitere Beispiele für GitHub Aktionsworkflows, die für Azure bereitgestellt werden, finden Sie im Repository [actions-workflow-samples](https://github.com/Azure/actions-workflow-samples)."}