Visual Studio

How to call the OpenShift REST API from C#

How to call the OpenShift REST API from C#

When you want to do automated tasks for builds and deployments with Red Hat OpenShift, you might want to take advantage of the OpenShift REST API. In scripts you can use oc CLI command which talks to the REST APIs. However there are times when it is more convenient to do this directly from your C# code without having to invoke an external program. This is the value of having an infrastructure platform that is exposed as services with an open API.

If you want to call the API from your C# code, you have to create a request object, call the API, and parse the response object. The upstream project, OpenShift Origin, provides a Swagger 2.0 specification and you can generate a client library for each programming language. Of course, C# is supported.  This isn’t a new approach, Kubernetes has a repository that is generated by Swagger Codegen.

For C#, we can use Microsoft Visual Studio to generate a C# client library for a REST API. In this article, I’ll walk you through the process of generating the library from the definition.

Continue reading “How to call the OpenShift REST API from C#”

Share
Remotely Debug an ASP.NET Core Container Pod on OpenShift with Visual Studio

Remotely Debug an ASP.NET Core Container Pod on OpenShift with Visual Studio

Last year, I wrote a blog post how to remotely debug your ASP.NET Core container on OpenShift with Visual Studio Code. Today I introduce how to remotely debug a pod using Visual Studio from your Windows computer. Sometimes you encounter an issue that happens only in the production environment. Remotely debugging a pod enables you to investigate such an issue.

Visual Studio and Visual Studio Code now support SSH as a transport protocol for remote debugging. If a remote host accepts an SSH connection, Visual Studio can do remote debugging using Visual Studio’s default feature. However, you need to use the oc command instead of an SSH client such as putty since Red Hat OpenShift pods don’t allow direct connections via SSH. The MIEngine debugger enables you to use any command for SSH connection.

Note:
All the steps below have been confirmed using a combination of Visual Studio 2017 (versions 15.7.2 and 15.8 preview2) on Windows 10 and OpenShift 3.9.

Continue reading “Remotely Debug an ASP.NET Core Container Pod on OpenShift with Visual Studio”

Share

Using Visual Studio with Linux (Hint: Windows is still required)

Running .NET on Linux, using the Red Hat Container Development Kit (CDK), means your Linux VM is running “headless” — you don’t have a desktop UI. You have a command line, and that’s it.

Note: If you aren’t running .NET on Linux, hop over to the Red Hat Developer’s web page and download the CDK to get started.

Red Hat Enterprise Linux’s built-in editor, VIM, which is launched by the command vi, is not a full-featured development environment. Not even close. That’s like saying a first-grader in the annual holiday play isn’t Meryl Streep; there’s a world of difference.

So what is a Windows developer to do? You’re accustomed to using Visual Studio — the worlds greatest development environment in my not-so-humble opinion — but you want to start developing code on your Linux VM.

The short answer is “Shared Volume”. Since we’re going to assume that the CDK is being used, this blog post will get down to the very specifics you need. Following these instructions, you can share a directory|folder (“directory” is the chosen vocabulary in Linux; “folder” is more frequently used in Windows) between the Linux VM and Windows, then use any editor to edit your code. Of course, you’ll choose Visual Studio, because it’s so awesome.

Continue reading “Using Visual Studio with Linux (Hint: Windows is still required)”

Share