Skip to main content
All docs
V25.1
  • Azure App Service (Linux) in Docker - Create an ASP.NET Core Reporting App Using CLI

    • 5 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 ASP.NET Core CLI Templates. If not installed, open the console and enter the following command:

      dotnet new install DevExpress.AspNetCore.ProjectTemplates
      

      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 application with a Report Designer and Document Viewer components. The project uses a Debian-based Docker image and ASP.NET Core distributed caching mechanism to cache reports and related documents.

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

    dotnet new dx.aspnetcore.reporting -n dxreportingtestapp --Dockerfile Debian --DocumentStorage DistributedCache
    

    For information about available options, run:

    dotnet new dx.aspnetcore.reporting -h
    

    For more information on the ASP.NET Core Reporting project template: Use DevExpress .NET CLI Templates to Create an ASP.NET Core Reporting App with a Report Designer.

    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