expressappframework-404614-deployment-asp-net-core-blazor-deploy-net-core-application-to-azure.md
This topic shows how to publish an XAF ASP.NET Core application (Blazor Server UI, Middle Tier Server, Web API Service) to the Azure App Service. For more information about other deployment methods, refer to the Microsoft documentation.
An Azure account with an active subscription.
An XAF ASP.NET Core application. This topic is based on the MainDemo Blazor Server demo application that ships with XAF. You can find this demo in the following folder: %PUBLIC%\Documents\DevExpress Demos 25.2\Components\XAF\MainDemo.NET.EFCore\CS\MainDemo.Blazor.Server.
Make sure you have the correct drawing engine for your application. If your project targets .NET 8+, add the following packages to your MainDemo.Blazor.Server project:
If you are running your application on Linux or macOS and it includes Reports, Office or Dashboards modules, additional setup may be required. If you encounter any issues with rendering or exporting documents and dashboards, review the following help topics:
Run Visual Studio with administrative privileges and open your Blazor solution (the MainDemo Blazor Server demo application is used in this example).
Log into your Microsoft account from Visual Studio.
In Solution Explorer , right-click the MainDemo.Blazor.Server project name and click Publish.
Select Azure and click Next.
Select the Azure App Service. In this tutorial, we publish the application to Azure App Service (Linux). Select this item and click Next.
On the App Service tab, click Create new.
If necessary, change the Name , Resource group , or Hosting Plan values and click Create.
Select the newly-created service and click Next.
On the API Management tab, check the Skip this step box and click Finish.
Close the Publish wizard.
Visual Studio creates a publishing profile for your project.
Scroll to the bottom of the Publish Profile Summary page and click the ellipsis button next to the SQL Server Database (ConnectionStrings:ConnectionString) service dependency. Select Connect from the ensuing menu.
Select Azure SQL Database and click Next.
Select an existing Azure SQL server or create a new instance. In this tutorial, we click New to create a new server.
Click New next to the Database server field.
Specify values for the Database server name , Location , Administrator username , and password fields. Click OK to close the dialog.
Click Create in the Azure SQL Database dialog.
Select the created database and click Next.
Specify credentials ( username and password ) for database connection. Best practice is to avoid using the same details as the username and password used in step 5.
Clear the NuGet packages check box and click Finish.
Close the dialog.
You can publish your Blazor Server app to the Azure App Service using one of the following options:
Azure SignalR Service (Recommended by Microsoft)
This approach requires additional setup in the MainDemo.Blazor.Server/Startup.cs file. Note that the specified step is implemented in the MainDemo application by default.
public void ConfigureServices(IServiceCollection services) {
services.AddSingleton(
typeof(HubConnectionHandler<>),
typeof(ProxyHubConnectionHandler<>)
);
For more information, refer to the following Microsoft page: Azure SignalR Service.
Application Request Routing (ARR) Affinity and WebSocketsYou can enable this functionality in the App Service settings on the Azure Portal. For more information, refer to the following Microsoft topic: Using the Application Request Routing Module.HTTP Long PollingThis approach uses multiple HTTP connections to send and receive data instead of WebSocket connection. In this case, the application displays error messages in the browser console.
This tutorial describes how to implement the first two approaches. For detailed steps, refer to sections below.
Note
Middle Tier Server uses Web Socket connection for communicating with Client application. Enable Web Sockets support option for this case as it mentioned below.
Ensure you have performed an additional setup step.
Scroll to the bottom of the Publish Profile Summary page and click the ellipsis button next to the SignalR service dependency. Select Connect from the ensuing menu.
Select an existing SingleR instance or create a new one. In this tutorial, we click New to create a new instance.
Specify required field values and click Create.
Select the created instance and click Next.
Click Finish to create the instance.
Close the dialog.
Open the Azure Portal.
Click App Services.
Click your App Service name.
Switch to the Configuration | General Settings page.
Enable WebSockets and ARR settings.
In the Visual Studio , click Publish next to the created profile.
Once the application is published, update the database (if necessary). Note that these steps (2-3) are not required for this example as our demo application automatically generates a demo database. You would normally need to perform these steps for your custom applications.
Switch to the Bash tab and launch the application in the database update mode.
Ensure that the application runs correctly in your default browser.
These deployment recommendations do not apply to all possible configurations and should not be considered comprehensive. We offer these instructions as a getting-started reference. Steps may vary depending on your operating system, installed software, and DevExpress versions. You, the developer, are responsible for the application, database, network, and other configurations based on your client, security, environment, and other requirements. We recommend that you review these settings with your database, network, and IT infrastructure administrators and consider their recommendations tailored to your case. We also recommend that you review Performance Optimization tips for deployed applications.
If you encounter problems, refer to the Deployment Troubleshooting Guide or review application logs.
Refer to the Microsoft documentation for more information about deploying ASP.NET Core and Blazor applications: