Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
327 stars 56 forks source link

Support for .NET5 Blazor WebAssembly apps #156

Closed MaxMommersteeg closed 4 years ago

MaxMommersteeg commented 4 years ago

Hi,

Today this article popped up in my feed: https://devblogs.microsoft.com/aspnet/azure-static-web-apps-with-blazor/ First of all, great feature!

I'm currently in the process of porting my Blazor WebAssembly 3.2 website to the latest .NET5 rc, so there is less work to be done once the stable release ships. Of course I immediately tried deploying using the Azure/static-web-apps-deploy@v.0.0.1-preview task. However the task failed giving me following error message:

error MSB4236: The SDK 'Microsoft.NET.Sdk.BlazorWebAssembly' specified could not be found.

Makes sense, because the logs are telling me that Microsoft Build Engine version 16.7.0 is used, where I think that 16.8.0 is a minimum requirement based on this article: Migrate from ASP.NET Core 3.1 to 5.0.

My question: Can we expect to see support for Blazor WebAssembly apps targetting net5.0 to be supported in the near future?

If necessary I can post the full logs from the failed deployment. Not sure if this issue is in the right place here, or should be created over at Microsoft/Oryx.

Thanks!

miwebst commented 4 years ago

Hi @MaxMommersteeg ,

Thanks for reaching this out! We can leave this here for tracking. We are working with the Oryx team to get this supported and will follow-up with any updates.

ardacetinkaya commented 4 years ago

Hope to have soon, I need to move from Azure Storage Static Web Site.

By the way, currently it is possible to have up to .NET 5.x versions Blazor apps. within Azure Storage Static Web Site Hope to have similiar approach in Static Web Apps. GitHub actions with Oryx.

Example; ``yaml name: blazorpwa

on: [push]

jobs: build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: 5.0.100-preview.8.20417.9
- name: Publish with dotnet
  run: dotnet publish Blazor.PWA/Blazor.PWA.csproj --configuration Release --output build
- uses: bacongobbler/azure-blob-storage-upload@v1.1.1
  with:
    source_dir: 'build/wwwroot'
    container_name: '$web'
    connection_string: ${{ secrets.ConnectionString }}
    sync: true

``

MaxMommersteeg commented 4 years ago

Yes, I'm actually doing the same thing right now. Only difference is that my CD-pipeline lives in Azure DevOps. I was very eager to try out Static Web Apps.

miwebst commented 4 years ago

Hey @ardacetinkaya you can actually use that same process with Static Web Apps today. Note the app_location below is the output of your previous step!

`steps:

ardacetinkaya commented 4 years ago

Hey @miwebst I am able to deploy my .NET 5-preview app within your suggestion, thanks a lot. 🤜🏼

From the output, I understand that if Oryx could not find version, it assumes that the output artifact is already built and ready for deployment. So App Location value becomes critical, I hope current default behavior in Azure portal have this info or Oryx have better approach for this soon.

---End of Oryx build logs--- Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support. Finished building app with Oryx Zipping App Artifacts Done Zipping App Artifacts Either no Api directory was specified, or the specified directory was not found. Azure Functions will not be created. Uploading build artifacts. Finished Upload. Polling on deployment. Status: InProgress. Time: 0.2076313(s) Status: Succeeded. Time: 15.4154469(s) Deployment Complete :)

Here is my *.yml for GitHub action for working GitHub Action for other

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: 5.0.100-preview.8.20417.9
      - name: Publish with dotnet
        run: dotnet publish Blazor.PWA/Blazor.PWA.csproj --configuration Release --output build
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v0.0.1-preview
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match you app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "build/wwwroot" # App source code path <---- THIS IS THE IMPORTANT PART 
          api_location: "Api" # Api source code path - optional
          app_artifact_location: "/Blazor.PWA/wwwroot" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######
miwebst commented 4 years ago

The logic that we use today is that if Oryx can't detect a platform (usually by looking at package.json) then we assume its static content and deploy that.

Also you should be able to use .NET 5 Blazors apps without any changes to the generated GitHub Action now! Oryx has fixed their detection issue.