Search

Chapter 5. Creating sample applications with .NET 8.0

download PDF

5.1. Creating the MVC sample application

s2i-dotnetcore-ex is the default Model, View, Controller (MVC) template application for .NET.

This application is used as the example application by the .NET S2I image and can be created directly from the OpenShift UI using the Try Example link.

The application can also be created with the OpenShift client binary (oc).

Procedure

To create the sample application using oc:

  1. Add the .NET application:

    $ oc new-app dotnet:8.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnet-8.0 --context-dir=app
  2. Make the application accessible externally:

    $ oc expose service s2i-dotnetcore-ex
  3. Obtain the sharable URL:

    $ oc get route s2i-dotnetcore-ex

5.2. Creating the CRUD sample application

s2i-dotnetcore-persistent-ex is a simple Create, Read, Update, Delete (CRUD) .NET web application that stores data in a PostgreSQL database.

Procedure

To create the sample application using oc:

  1. Add the database:

    $ oc new-app postgresql-ephemeral
  2. Add the .NET application:

    $ oc new-app dotnet:8.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-persistent-ex#dotnet-8.0 --context-dir app
  3. Add environment variables from the postgresql secret and database service name environment variable:

    $ oc set env dc/s2i-dotnetcore-persistent-ex --from=secret/postgresql -e database-service=postgresql
  4. Make the application accessible externally:

    $ oc expose service s2i-dotnetcore-persistent-ex
  5. Obtain the sharable URL:

    $ oc get route s2i-dotnetcore-persistent-ex
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.