Installing .NET 5.0 on AWS EC2 Running RHEL 7

Posted on August 12, 2021

Microsoft’s instructions for installing .NET 5.0 on RHEL require an active Red Hat subscription so that you can enable the rhel-7-server-dotnet-rpms repository:

$ subscription-manager repos --enable=rhel-7-server-dotnet-rpms

Although the cost of a Red Hat subscription is included in the AWS EC2 charges for Amazon’s RHEL 7 AMI, the AMI is not configured to use a typical Red Hat subscription. Instead, it is set up to use Red Hat Update Infrastructure (RHUI) hosted in AWS. This allows machines based on Amazon’s RHEL 7 AMI to access all of the software and updates provided by a standard RHEL 7 subscription, without registering a subscription with Red Hat.

The AWS RHEL images are configured with access to several repositories. If the rhel-7-server-dotnet-rpms repo is available, then we can replace the subscription-manager step with:

yum-config-manager --enable $REPONAME

Let us see which repositories are provided by the RHUI:

$ yum repolist all
Loaded plugins: amazon-id, search-disabled-repos
repo id                                                     repo name                 status
rhel-7-server-dotnet-rhui-debug-rpms/7Server/x86_64         dotNET on RHEL Debug RPMs disabled
rhel-7-server-dotnet-rhui-rpms/7Server/x86_64               dotNET on RHEL RPMs for R disabled
rhel-7-server-dotnet-rhui-source-rpms/7Server/x86_64        dotNET on RHEL Source RPM disabled
rhel-7-server-rhui-debug-rpms/7Server/x86_64                Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-extras-debug-rpms/x86_64                 Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-extras-rpms/x86_64                       Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-extras-source-rpms/x86_64                Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-optional-debug-rpms/7Server/x86_64       Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-optional-rpms/7Server/x86_64             Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-optional-source-rpms/7Server/x86_64      Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-rh-common-debug-rpms/7Server/x86_64      Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-rh-common-rpms/7Server/x86_64            Red Hat Enterprise Linux  enabled:    243
rhel-7-server-rhui-rh-common-source-rpms/7Server/x86_64     Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-rpms/7Server/x86_64                      Red Hat Enterprise Linux  enabled: 32,037
rhel-7-server-rhui-source-rpms/7Server/x86_64               Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-supplementary-debug-rpms/7Server/x86_64  Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-supplementary-rpms/7Server/x86_64        Red Hat Enterprise Linux  disabled
rhel-7-server-rhui-supplementary-source-rpms/7Server/x86_64 Red Hat Enterprise Linux  disabled
rhel-server-rhui-rhscl-7-debug-rpms/7Server/x86_64          Red Hat Software Collecti disabled
rhel-server-rhui-rhscl-7-rpms/7Server/x86_64                Red Hat Software Collecti disabled
rhel-server-rhui-rhscl-7-source-rpms/7Server/x86_64         Red Hat Software Collecti disabled
rhui-client-config-server-7/x86_64                          Custom Repositories - Red enabled:     14
repolist: 32,294

As you can see, at the time of writing, the relevant repository is called rhel-7-server-dotnet-rhui-rpms. (If you do not see this repository listed, be sure to update the rh-amazon-rhui-client package with yum update rh-amazon-rhui-client. The dotnet repository was not included in older versions of the package.)

Let us enable the repository:

yum-config-manager --enable rhel-7-server-dotnet-rhui-rpms

Now you should be able to continue following Microsoft’s documentation for installing .NET, picking up after the subscription-manager step.