Skip to main content
All docs
V23.2

Azure App Service (Linux) in Docker - Create an ASP.NET Core Reporting App Using CLI

  • 7 minutes to read

This topic uses a command-line interface to create a sample ASP.NET Core DevExpress Reporting application that includes Document Viewer and Report Designer, and deploys that application to Azure App Services using a Docker Container from the Azure Container Registry.

Prerequisites

  1. An Azure account with an active subscription.
  2. Your personal DevExpress NuGet credentials. Refer to the following help topic for instructions on how to obtain the feed URL and authorization key, and register the online NuGet feed in your development environment: Choose Between Offline and Online DevExpress NuGet Feeds.
  3. The latest version of Azure Command-Line Interface (CLI). For instructions, review the following topic: Install Azure CLI on Windows.
  4. The latest version of Docker desktop. You can find more information about Docker in the following topic: Get Docker.
  5. Installed DevExpress CLI Templates. If not installed, open the console and enter the following command:

    dotnet new install DevExpress.DotNet.Web.ProjectTemplates::23.2.6
    

    The console displays the list of templates installed on your machine from this package.

Important Disclaimer

The 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 tailoring their recommendations to your case.

Create a Sample ASP.NET Core DevExpress Reporting Application

Create a sample .NET 6 application with a Report Designer and Document Viewer components. The project uses a Debian-based Docker image and an ASP.NET Core distributed caching mechanism to cache reports and related documents.

Run the following command to create a new dxreportingtest project from the template:

dotnet new dx.reporting --name dxreportingtestapp --Dockerfile Debian --framework net6.0 --DocumentStorage DistributedCache

For information about available options, run:

dotnet new dx.reporting -h
Template Command Options

The following command line parameters are available:

-nf, --nuget-feed <nuget-feed>
Specifies the NuGet Feed URL. Refer to https://nuget.devexpress.com/#feed-url and login to your account to obtain your Feed URL.
-ad, --add-designer
Specifies whether to create a web page with the Report Designer. The default value is true.
-av, --add-viewer
Specifies whether to create a web page with a Document Viewer. The default value is true.
-ads, --add-data-source
Specifies whether to create a sample connection string and register it in the Report Designer to create SQL Data Sources in the Report Wizard and Data Source Wizard. The connection string is also used to register a predefined data source. The default value is true.
-ajs, --add-json-data-connection-storage
Specifies whether to create a storage and register it to create JSON Data Sources in the Report Wizard and Data Source Wizard. For the storage to work correctly, ensure that the Newtosoft.Json package is installed. The default value is false.
-ao, --add-data-object
Specifies whether to add a sample data object to an application and register this data object to create Object Data Sources in the Report Wizard and Data Source Wizard. The default value is false.
-rte, --enable-rich-text-editor
Specifies whether to add an in-line Rich Text Editor for the RichText control. The default value is false.
-dfb, --Dockerfile <None|Debian|...>

Creates a Dockerfile based on the selected OS. Review the following online example for more information: How to Use the DevExpress CrossPlatform Drawing Engine in an ASP.NET Core Application. Select None to not enable Docker support.

None (defaut)
Skip docker support.
Debian
Debian-based Dockerfile.
Alpine
Alpine-based Dockerfile.
Ubuntu
Ubuntu-based Dockerfile.
openSUSE
openSUSE-based Dockerfile.
Amazon Linux
Amazon Linux based Dockerfile.
-f, --framework <net6.0|net7.0|...>
Specifies the target framework for the project.
net6.0 (default)
The target framework is .Net6.0
net7.0
The target framework is .Net7.0
net8.0
The target framework is .Net8.0
-D, --DocumentStorage <InMemory|XPO|...>
Specifies the storage type to cache documents that the report creates. For more information, review the following help topic: Web Document Viewer Cache Management.
InMemory (default)
Default cache that stores objects directly in memory without serialization, optimized for frequent operations.
XPO
Implements database cache based on the XPO library, designed for multi-instance applications to prevent cache data loss.
File
Configures the reporting engine to store documents generated by reports on disk instead of in memory.
DistributedCache
Enables cache as external service that uses ASP.NET Core distributed caching mechanism and can be shared by multiple application servers.
Azure
Configures the application to use Azure caching services.

Log in to Azure

Enter the following command:

az login

A new browser window opens and prompts you to complete the authentication process. After successful authentication, your subscription details are displayed in the terminal. Note the id key as it is required when you create the service principal.

[
  {
    "cloudName": "AzureCloud",
    "homeTenantId": "{a homeTenantId identifier}",
    "id": "{your subscription identifier}",
    "isDefault": true,
    "managedByTenants": [],
    "name": "Visual Studio Professional Subscription",
    "state": "Enabled",
    "tenantId": "{a tenantId identifier}",
    "user": {
      "name": "{your user name}",
      "type": "user"
    }
  }
]

Create a Service Principal

An Azure service principal acts as an impersonation for a user in Azure AD.

Run the following command to create a service principal:

az ad sp create-for-rbac --name {specify any name} --scopes /subscriptions/{your subscription identifier} --role owner

You can specify any name for a service principal. The value of {your subscription ID} is the id field from the successful login output.

After creating the service principal account, the terminal displays appId and password. These credentials are necessary to log in to the container registry.

Create a Container Registry

  1. Create a new resource group:

    az group create --name DXAzureGr --location westus
    

    This command creates a DXAzureGr group at a location in the Western US. You can specify any name for the resource group. A location name is one of the values listed with the following command:

    az account list-locations
    
  2. Create a new container registry:

    az acr create --resource-group DXAzureGr --name dxazuretest001 --sku Basic
    

    This command creates a dxazuretest001 registry in the DXAzureGr group. The registry name must be unique within Azure and must contain 5-50 lowercase alphanumeric characters. Make a note of the `loginServer’ field in the output. You will need it later to name a docker image.

Build a Docker Image

The sample Reporting project dxreportingtestapp created earlier includes a Dockerfile located in the root project folder. Navigate to that folder and run the following command:

docker build -t dxazuretest001.azurecr.io/dxreportingtestapp --secret id=dxnuget,source=secrets.dev.yaml .

The dxazuretest001.azurecr.io is the loginServer field value from the container registry creation output in the previous step.

You can test the application and run the Docker image locally using the following command:

docker run -p 8080:80 dxreportingtestapp:latest

The application will run on port 8080.

Push an Image to the Registry

  1. Log in to the Azure Container registry using the following command:

    az acr login --name dxazuretest001
    
  2. Push the image to a registry using the following command:

    docker push dxazuretest001.azurecr.io/dxreportingtestapp:latest
    
  3. Remove the dxreportingtestapp:latest image from your local Docker environment:

    docker rmi dxazuretest001.azurecr.io/dxreportingtestapp:latest
    

Create a Container

The following command creates a container in a container group DXAzureGr with 1 core, 1Gb of memory, a public IP address, port 80, and the DNS name label dxreporting001:

az container create --resource-group DXAzureGr --name dxazuretest001 --image dxazuretest001.azurecr.io/dxreportingtestapp:latest --cpu 1 --memory 1 --registry-login-server dxazuretest001.azurecr.io --registry-username {appId created for service principal} --registry-password {password created for service principal} --ip-address Public --dns-name-label dxreporting001 --ports 80

The appId and password credentials are obtained in the Create a Service Principal step. The dns name label must be unique for a container group with public IP.

When the container is created successfully, the output includes the application FQDN: dxreporting001.westus.azurecontainer.io.

Test the Application

Open the published application in your browser:

dxreporting001.westus.azurecontainer.io

ASP.NET Core Reporting App in a Docker Container in App Service from Azure Container Registry