Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could someone please provide detailed instructions on how to publish a Blazor (ASP.NET Core hosted) app to Azure. #10509

Closed
rxelizondo opened this issue May 24, 2019 · 22 comments

Comments

Projects
None yet
@rxelizondo
Copy link

commented May 24, 2019

I would like to publish my Blazor (ASP.NET Core hosted) app to Azure to get a better feel on how the Blazor app behaves once deployed as well as to make my app easily available to other people to test.

So far, I have tried several things (such as adding ASP.NET Core 3.0 Runtime extensions to my Azure web app, deploying self-contained apps etc) but something always goes wrong at one point or another.

So if at all possible, can someone please provide detailed instructions on how to deploy a Blazor (ASP.NET Core hosted) app developed with the latest version of .NET into Azure (preferably using the visual studio Azure builtin deployment process)?

Thanks.

@elgunhuseynli

This comment has been minimized.

Copy link

commented May 24, 2019

Blazor apps are client side rendered. It means even you can deploy them to github pages for free, like this:

https://blazor-demo.github.io/

For server side blazor, take a look at this tutorial.

@jkotalik

This comment has been minimized.

Copy link
Member

commented May 24, 2019

@bradygaster @danroth27 do we have anything official for this?

@jkotalik jkotalik added the area-mvc label May 24, 2019

@jkotalik jkotalik added this to the Discussions milestone May 24, 2019

@rxelizondo

This comment has been minimized.

Copy link
Author

commented May 24, 2019

@elgunhuseynli This is a Blazor (ASP.NET Core hosted) solution, there are client and server side projects, the client runs locally but the server side needs to be hosted (in my case on Azure)... unless I am missing something.

Edit:

I followed the link you provided after your edited your post. The instructions there are instructions that I have followed already but the publish process fails, As far as I can see, Azure does not like .NET 3.0 Core.

@rxelizondo rxelizondo changed the title Could someone please provide detailed instructions in how to publish a Bazor app to Azure. Could someone please provide detailed instructions in how to publish a Blazor (ASP.NET Core hosted) app to Azure. May 24, 2019

@rxelizondo rxelizondo changed the title Could someone please provide detailed instructions in how to publish a Blazor (ASP.NET Core hosted) app to Azure. Could someone please provide detailed instructions on how to publish a Blazor (ASP.NET Core hosted) app to Azure. May 24, 2019

@henk787

This comment has been minimized.

Copy link

commented May 24, 2019

For Client Side:

  • Nothing special, this can be hosted as static files anywhere.

For Server Side:

  • Create a Servicce Plan, select it in the Portal.
    • Go to Extensions, add the ASP.NET Core 3.0 (x86) Runtime , Preview xx
      • Pick x86 when you are on the F1: free tier.
    • Go to Configuration, Settings, General settings
      • enable websockets

@pranavkm pranavkm added area-blazor and removed area-mvc labels May 28, 2019

@danroth27

This comment has been minimized.

Copy link
Member

commented May 28, 2019

@rxelizondo When publishing an ASP.NET Core 3.0 based app to Azure App Service you need to publish the app as a self-contained app (not framework dependent). This will result in the .NET Core runtime being deployed with the app, which is required because .NET Core 3.0 is not deployed to Azure App Service yet (it's still in preview).

However, even if you do a self-contained deployment you will most likely then hit an issue with publishing the Blazor part of the application due to a known issue in the Web SDK: aspnet/websdk#604. This issue has been fixed for Preview 6, which should ship sometime in June.

Sorry about the inconvenience!

@rxelizondo

This comment has been minimized.

Copy link
Author

commented May 28, 2019

@henk787 Just wanted to let you know that I just followed your instructions and the app actually worked. Looks like the key was to enable WebSocket (not sure why this is required for a ASP.NET Core hosted application). You will still get a message during the deployment saying that .NET 3 Core is not supported but if you ignore the message and move on the deployment actually works.

I am curious as to why WebSocket is required, specially because once things are working I can disable WebSocket and things continue to work just fine, so I guess WebSocket is only required during initial deployment.

In any event, I am not going to worry about that right now, just wanted to take a moment to let you know that your post was very helpful.

@danroth27

This comment has been minimized.

Copy link
Member

commented May 28, 2019

@rxelizondo WebSockets are required when publishing a server-side Blazor app. Publishing a server-side Blazor app to Azure App Service should work fine today as long as you do a self-contained deployment. However, we also recommend using the Azure SignalR Service with server-side Blazor apps, which should remove the need to enable WebSockets and will dramatically improve the ability of your app to scale out.

@rxelizondo

This comment has been minimized.

Copy link
Author

commented May 29, 2019

@danroth27 I am confused because this is an ASP.NET Core hosted project. So unless I am mistaken, this type of project creates a Blazor app that runs completely in the local browser (local Blazor app) and an ASP.NET Core project ruining on the server (essentially WebAPI calls). So in effect, we have a local Blazor app communicating with the WebAPI server using regular HTTP calls (not via WebSockets).

On you reply, you mention server-side Blazor apps but ASP.NET Core hosted projects are not server-side Blazor apps are they?

Assuming that what I said above makes any scene, why are WebSockets needed?

@danroth27

This comment has been minimized.

Copy link
Member

commented May 29, 2019

@rxelizondo That is strange - WebSockets are not generally required by ASP.NET Core hosted Blazor apps. Unless you also are using SignalR in the Server project?

@rxelizondo

This comment has been minimized.

Copy link
Author

commented May 29, 2019

@danroth27 I am not using SignalR (at least I don't think so). You can easily reproduce the issue using the built in template that comes with Visual Studio. Here is how:

  1. Open Visual Studio.
  2. Create an ASP.NET Core Web Application.
  3. Choose (ASP.NET Core Hosted) template.
  4. Right click the server project and click publish.
  5. When prompted to create an Azure App Service, choose 'Create New'.
  6. Do whatever you need to do to publish the app.
  7. When the project finishes publishing, you should get a web page with an error (HTTP Error 500.0 - ANCM In-Process Handler Load Failure).

EDIT:
7.5) Go back to Visual Studio and click 'Continue' when you get the message about .NET Core 3 not being supported. I don't think this matter but that is what I do.

  1. Login to Azure and install the ASP.NET Core 3.0 (x86) Runtime extension on the app service.
  2. Try running the app again (refresh the page) and it will fail again (same error).
  3. Now enable WebSockets on the app service.
  4. Try running the Blazor app again (refresh the page) and this time it will work.

I assume that the Blazor (ASP.NET Core Hosted) built in template that comes with Visual Studio does not use SignalR. And even if it did, the failure is happening before the app even gets a chance to start executing.

For fun, go back to the app service and disable WebSockets. The application will continue to work without a hitch.

@henk787

This comment has been minimized.

Copy link

commented May 29, 2019

@rxelizondo - I did this a few weeks ago, for a server-side app.

I cannot confirm your point 9: It did at first work w/o WebSockets, just crashed when there were many events (MouseMove). A known issue here that pointed me to enable WebSockets.

@rxelizondo

This comment has been minimized.

Copy link
Author

commented May 29, 2019

@danroth27 @henk787 - I am closing this issue because I am not sure this is worth pursuing right now since I already have a workaround and a proper fix is on its way. If this becomes an issue later again then I may re open it.

Thanks.

@rxelizondo rxelizondo closed this May 29, 2019

@gojanpaolo

This comment has been minimized.

Copy link

commented Jun 5, 2019

just followed @rxelizondo #10509 (comment) and it works like a charm! :)

I also tried using just the cli similar to this tutorial but creating a new blazor project instead. And then git push to azure but it doesn't work even when I install the .NET Core 3.0 extension in Azure and enabling WebSockets

@jorgearana

This comment has been minimized.

Copy link

commented Jul 5, 2019

@henk787 Just wanted to let you know that I just followed your instructions and the app actually worked. Looks like the key was to enable WebSocket (not sure why this is required for a ASP.NET Core hosted application). You will still get a message during the deployment saying that .NET 3 Core is not supported but if you ignore the message and move on the deployment actually works.

I am curious as to why WebSocket is required, specially because once things are working I can disable WebSocket and things continue to work just fine, so I guess WebSocket is only required during initial deployment.

In any event, I am not going to worry about that right now, just wanted to take a moment to let you know that your post was very helpful.

Hi, please let us know how you did it. I follow several times the steps and continues the error HTTP Error 500.0 - ANCM In-Process Handler Load Failure. And I do not know anyone who has been able to do it

@jorgearana

This comment has been minimized.

Copy link

commented Jul 5, 2019

@danroth27 I am not using SignalR (at least I don't think so). You can easily reproduce the issue using the built in template that comes with Visual Studio. Here is how:

  1. Open Visual Studio.
  2. Create an ASP.NET Core Web Application.
  3. Choose (ASP.NET Core Hosted) template.
  4. Right click the server project and click publish.
  5. When prompted to create an Azure App Service, choose 'Create New'.
  6. Do whatever you need to do to publish the app.
  7. When the project finishes publishing, you should get a web page with an error (HTTP Error 500.0 - ANCM In-Process Handler Load Failure).

EDIT:
7.5) Go back to Visual Studio and click 'Continue' when you get the message about .NET Core 3 not being supported. I don't think this matter but that is what I do.

  1. Login to Azure and install the ASP.NET Core 3.0 (x86) Runtime extension on the app service.
  2. Try running the app again (refresh the page) and it will fail again (same error).
  3. Now enable WebSockets on the app service.
  4. Try running the Blazor app again (refresh the page) and this time it will work.

I assume that the Blazor (ASP.NET Core Hosted) built in template that comes with Visual Studio does not use SignalR. And even if it did, the failure is happening before the app even gets a chance to start executing.

For fun, go back to the app service and disable WebSockets. The application will continue to work without a hitch.

Hi, please let us know how you did it. I follow several times the steps and continues the error HTTP Error 500.0 - ANCM In-Process Handler Load Failure. And I do not know anyone who has been able to do it

@danroth27

This comment has been minimized.

Copy link
Member

commented Jul 6, 2019

Hi folks,

Sorry about the confusion here! Please note that .NET Core 3.0 has not been deployed to Azure. To deploy an app that uses a preview version of .NET Core that hasn't been deployed you typically need to do either one of two things: 1. Deploy the app as a self-contained app so that it brings the runtime with it, or 2. Add a preview Azure App Service site extension to add the required runtime. Failing to do one of these two things will result in a 500 error that the server can't find the required runtime.

The site extension for .NET Core 3.0 Preview 6 unfortunately has an issue with it that prevents it being deployed to Azure right now. This will get fixed for Preview 7. In the meantime you'll need to deploy your app as a self-contained app (advanced setting in the VS publishing dialog).

There is also a separate problem that causes publishing ASP.NET Core hosted Blazor apps to fail. To work around this issue you need to edit the generated publishing profile (.pubxml file under the Properties folder) for the app to remove the TargetFramework element.

I hope this helps!

@vpaulino

This comment has been minimized.

Copy link

commented Jul 9, 2019

When can we expect preview 7? Currently Im deploying from Continuous Deployment task from TFS enterprise to a slot and having the same issue!

@danroth27

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

@vpaulino We hope to ship Preview 7 sometime next week.

@MACEL94

This comment has been minimized.

Copy link

commented Jul 11, 2019

Hi folks,

Sorry about the confusion here! Please note that .NET Core 3.0 has not been deployed to Azure. To deploy an app that uses a preview version of .NET Core that hasn't been deployed you typically need to do either one of two things: 1. Deploy the app as a self-contained app so that it brings the runtime with it, or 2. Add a preview Azure App Service site extension to add the required runtime. Failing to do one of these two things will result in a 500 error that the server can't find the required runtime.

The site extension for .NET Core 3.0 Preview 6 unfortunately has an issue with it that prevents it being deployed to Azure right now. This will get fixed for Preview 7. In the meantime you'll need to deploy your app as a self-contained app (advanced setting in the VS publishing dialog).

There is also a separate problem that causes publishing ASP.NET Core hosted Blazor apps to fail. To work around this issue you need to edit the generated publishing profile (.pubxml file under the Properties folder) for the app to remove the TargetFramework element.

I hope this helps!

I was searching for this!

Thank you dan!

@rxelizondo

This comment has been minimized.

Copy link
Author

commented Jul 13, 2019

@danroth27: This is failing again, even after following the steps you provided, when you publish a brand new Blazor (ASP.NET Core hosted) project, you wont get an error, however, when you try to access the app all you get is a page can't found error:

This xyz.azurewebsites.net page can’t be found No webpage was found 
for the web address: https://xyz.azurewebsites.net/

HTTP ERROR 404

Very frustrating.

@bradygaster

This comment has been minimized.

Copy link
Member

commented Jul 18, 2019

After talking to a few of our developers who are working on Preview 7 and the supporting packages that will need to be updated for the Azure SignalR Service, I came up with a series of steps for folks who want to publish a server-side Blazor app running ASP.NET Core 3.0 Preview 7 to App Service on Linux. We're working to mitigate these steps, and some of them will just go away once Preview 7 is published.

  1. Create the server-side Blazor project.

  2. Add the NuGet package feed URL https://www.myget.org/F/azure-signalr-dev/api/v3/index.json to your list of feeds in Visual Studio's options window, via a nuget.config file, or via the command below.

    nuget.exe install Microsoft.Azure.SignalR -Version 1.1.0-preview1-10442 -Source https://www.myget.org/F/azure-signalr-dev/api/v3/index.json
    

    Note: this step will be unnecessary once Preview 7 ships, as the package will be on nuget.org.

  3. Publish your server-side Blazor app to Azure App Service Linux, using the self-contained option, selecting .NET Core 3.0 Preview 7.

    self-contained

  4. When you publish the app to App Service on Linux, create (or select) an Azure SignalR Service instance. See below how to add the instance, as well as what you'll see after you add the instance.

    image

  5. After the app has been published, go to the Configuration blade of the App Service.

    1. Verify the Azure__SignalR__ConnectionString setting is correct for your Azure SignalR Service instance.
    2. Verify the Azure__SignalR__StickyServerMode setting is set with a value of Required.
    3. Add the ASPNETCORE_HOSTINGSTARTUPASSEMBLIES setting, with a value of Microsoft.Azure.SignalR. This step will be omitted in a future release.
  6. Restart your App Service and reload it, and you should see that the site negotiates with the SignalR Hub, and then a connection is established with Azure SignalR Service, through which all WebSocket traffic will now flow.

If you try this and experience any other issues, please add a comment below. Know we're working to make this process as smooth as possible, and things will be much smoother once Preview 7 is released.

cc @danroth27

@MACEL94

This comment has been minimized.

Copy link

commented Jul 21, 2019

@vpaulino We hope to ship Preview 7 sometime next week.

Any news?
I saw preview-8 packages yesterday and today but i can't install them because of a missing Mono package(preview 8) that i'm not able to find on nuget.

Anyway thank you again guys for the help, i'm trying to sort it out to do a project for my university, this seems so cool!

I got the same error as rxelizondo after following your steps, my app is a full stack blazor so server,client and shared projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.