Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Simplifying ASP.NET applications on OpenShift with the ASP.NET Core S2I Builder

 

June 16, 2016
Andrew Block
Related topics:
.NETKubernetes
Related products:
Red Hat OpenShift Container Platform

Share:

    With recent changes the to the.NET ecosystem, developers of popular languages such as C# now have the ability to develop and deploy .NET applications across multiple platforms including OSX and Linux. This is made possible thanks to the .NET Core, a modular implementation of the .NET framework capable of supporting both web and console applications.

    Aside from opening up opportunities to a new pool of potential developers, .NET Core also enabled these applications to take advantage of certain technologies they were previously restricted from. One of these technologies in particular is Linux Containers. Containerized .NET applications can now benefit from a wide range of features built into containerization technologies such as Docker. This includes a rapid application deployment cycle and portability across machines whether they are located on physical, virtual or hosted in a cloud environment.

    In addition, since these applications are running in containers, they are also eligible to be run in OpenShift, Red Hat’s Platform as a Service product. OpenShift provides the flexibility to manage and run containerized applications while also providing the tools necessary for developers to be productive. It is this ecosystem that gives developers the flexibility and freedom to easily build and deploy applications, without needing to be concerned about the underlying infrastructure.

    OpenShift Source to Image and .NET

    To abstract developers from the underlying Docker image build process, OpenShift provides a feature called Source to Image (S2I). S2I takes an existing image in the docker format, packages an application on top of that existing image, and creates a new container image (also in the Docker format) for deployment onto OpenShift. This originating image is called an S2I builder image and contains the logic to build, deploy, and eventually run the layered application. There are two primary scripts that is used by S2I.

    • assemble – Describes the steps necessary to prepare the source code for deployment. This process typically includes dependency resolution and packaging
    • run - Instructions on how to run the container image to support deployed applications

    These scripts are included in an S2I builder that is available for ASP.NET developers to leverage for deploying their applications into OpenShift. The source code for the builder is located on GitHub at the following location:

    https://github.com/openshift-s2i/s2i-aspnet

    The S2I scripts in this builder utilize the dotnet command line interface (CLI) to prepare the application for deployment and to support the running application. Inside the S2I run script, the dotnet run command is used in conjunction with the application's project.json file to start the application from the previously assembled components. The application itself is deployed on a kestrel based web server that listens on port 5000 from all network interfaces. This allows the application to be invoked by other applications within the OpenShift cluster or connected to a route for external ingress.

    That’s it! The ASP.NET Core framework does the rest to launch the application and make it available for invocation.

    Deploying a Sample Application

    With an understanding of how applications are assembled and run using the ASP.NET S2I builder, let’s walk through how a sample application can utilize the builder to simplify the deployment of ASP.NET applications into an OpenShift environment. The sample application is also located on GitHub and contains both the application source code and an OpenShift template that can be used to set up the necessary project components.

    https://github.com/openshift-s2i/s2i-aspnet-example

    Clone the repository onto your local machine to have assets available to add to OpenShift

    git clone https://github.com/openshift-s2i/s2i-aspnet-example

    The first step when interacting with OpenShift is to login to the environment and create a new project for the sample application. Using the OpenShift command line interface (CLI), create a project called ose-dotnet

    oc new-project ose-dotnet

    Next, add the template to the project so it can be used as the baseline for creating .NET applications. The template is located in a file called aspnet-s2i.json in the templates directory. Execute the following command from the root of the sample application repository to add the aspnet-s2i template to the project:

    oc create –f  templates/aspnet-s2i-template.json

    Now, create an application from the template. The GIT_URI template parameter provides a generic variable that promotes template reuse by multiple applications. Execute the following command specifying the aspnet-s2i template and the location of the sample application's repository to create the application in OpenShift.

    oc new-app --template=aspnet-s2i –p GIT_URI=https://github.com/openshift-s2i/s2i-aspnet-example

    A new S2I build will be initiated to clone the source code from the git repository into the builder which will produce the new image. Once complete, a new deployment of the image will occur. The template also included a route so that the application can be invoked from outside the OpenShift environment. The hostname of the route can be discovered by running the oc get routes command. A result similar to the following will be returned.

    NAME HOST/PORT PATH SERVICE LABELS INSECURE POLICY TLS TERMINATION
     aspnet-app aspnet-app-ose-dotnet.rhel-cdk.10.1.2.2.xip.io aspnet-app app=aspnet-app,template=aspnet-s2i

    The particular deployment of OpenShift is running in the Red Hat Container Development Kit (CDK) and provides a localized environment for working with OpenShift to accelerate the development process.

    Copy the hostname into a browser to verify the application is accessible

    S2I ASP.NET Core

    Congratulations! You just deployed your first ASP.NET application on OpenShift. To allow additional teams to take advantage of this simplified workflow for deploying .NET applications of the own, the template from the sample application can be added to the global openshift project which will make the template accessible by all authenticated users. To do so, execute the following command from the root of the sample application repository:

    oc create –f  templates/aspnet-s2i-template.json -n openshift

    The .NET Core framework has made it easier for ASP.NET developers to expand the reach of their applications. Through the use of the ASP.NET Core S2I builder, a simplified process is available for developers to quickly build and deploy their applications to OpenShift and to take advantage of all of the features available within the platform.

    For additional information and articles on .NET Core visit our .NET Core web page for more on this topic.

    Last updated: May 29, 2023

    Recent Posts

    • How to deploy language models with Red Hat OpenShift AI

    • AI search with style: Fashion on OpenShift AI with EDB

    • What qualifies for Red Hat Developer Subscription for Teams?

    • How to run OpenAI's gpt-oss models locally with RamaLama

    • Using DNS over TLS in OpenShift to secure communications

    What’s up next?

     

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue