Nish's technology blog

Direct WordPress URL

Adding a lambda target with EventBridge

Unlike Kafka or Kinesis, you don’t really have a concept of a persisted topic or stream to which multiple consumers can consume from. Instead you need to set rules/targets, so it’s more like a concious push than a pull. Arguably, this does add a little bit of coupling in the sense that the producing team … <a href="" class="more-link">Continue reading <span class="screen-reader-text">Adding a lambda target with EventBridge</span></a>

Amazon EventBridge

Amazon EventBridge is not an apples-to-apples comparable to Kafka or Kinesis, but it does enable event driven software architectures and is a serverless offering, so if you are heavily invested in AWS, it is very easy to move forward with it. It’s trivial to create an event bus (Amazon calls them custom event buses, but … <a href="" class="more-link">Continue reading <span class="screen-reader-text">Amazon EventBridge</span></a>

ASP.NET Core 3.1, Windows 8.1, and Http2

If you are on Windows 8.1, and you are attempting to run an ASP.NET Core 3.1 Web Application, you’ll have run into the dreaded ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY error message. Here’s the workaround. Add this to your appsettings.Development.json file.

.NET Core OData client using Microsoft.OData.Client

If you are using .NET Core, you’ll have quickly found that the .NET OData packages don’t work with it. Fortunately, the most recent (as of today) version of Microsoft.OData.Client (v7.5.0) works fine with .NET Core. Once you add the package to your project, you get a T4 file generated for you (.tt extension). Edit the … <a href="" class="more-link">Continue reading <span class="screen-reader-text">.NET Core OData client using Microsoft.OData.Client</span></a>

ASP.NET Core, OData, and Swashbuckle – workaround for error

If you are trying to use Swashbuckle with an ASP.NET Core project that uses OData, you are going to get an error on the swagger endpoint. The error will be something like this. InvalidOperationException: No media types found in ‘Microsoft.AspNet.OData.Formatter.ODataOutputFormatter.SupportedMediaTypes’. Add at least one media type to the list of supported media types. Until one … <a href="" class="more-link">Continue reading <span class="screen-reader-text">ASP.NET Core, OData, and Swashbuckle – workaround for error</span></a>

OData with ASP.NET Core

If you are writing .NET Core REST services to expose data entities, I would recommend using OData now that ASP.NET Core support has been added. You need to add the Nuget package – Microsoft.AspNetCore.OData (at the time of writing, the latest stable version is 7.0.1). One caveat is that Swagger and Swashbuckle will not work … <a href="" class="more-link">Continue reading <span class="screen-reader-text">OData with ASP.NET Core</span></a>

Handling application lifetime events for a hosted service

The IApplicationLifetime interface allows hosted services to gracefully handle startup and shutdown events. It has three properties of type CancellationToken. ApplicationStarted ApplicationStopping ApplicationStopped You can register callbacks for one or more of those notifications. The IApplicationLifetime interface also has a StopApplication method which unsurprisingly does just that, which is to terminate the current application. The screenshot below … <a href="" class="more-link">Continue reading <span class="screen-reader-text">Handling application lifetime events for a hosted service</span></a>

Generic hosted services in .NET Core using IHost and IHostedService

An approach used to simulate a long running or permanently running background task for cloud services is to deploy a REST API, and to invoke end-points on the API from a cloud-native event handler (AWS Lambdas or Azure Functions). When migrating on-prem Windows services, people would take this approach when the other option would have … <a href="" class="more-link">Continue reading <span class="screen-reader-text">Generic hosted services in .NET Core using IHost and IHostedService</span></a>

VC++ 2015 – Lazy generators

If you have ever used iterators in C# or Visual Basic, then this is essentially the same thing. You would need to enable the new experimental /await compiler option, same as in the previous blog entry. Calling this method would be fairly straightforward. And here’s the expected output. I added the console output to demonstrate … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VC++ 2015 – Lazy generators</span></a>

VC++ 2015 – Using resumable functions

Visual C++ 2015 has a new compiler option called /await that can be used to write and call resumable functions. Do note that this is an experimental feature and even the associated headers are in an experimental sub-directory. There is no UI option to turn this compiler option in VS 2015, so you would need … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VC++ 2015 – Using resumable functions</span></a>

VS14 CTP – Implement Pure Virtuals

This refactoring option implements stub-functions for all pure virtuals in one or all base classes. Here’s an example. If you right click on a specific base class, you’ll get an option to just implement pure virtuals for that class. If you right click on the derived class name, you’ll get the option to implement all … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VS14 CTP – Implement Pure Virtuals</span></a>

VS14 CTP – Move Definition Location

The CTP adds a refactoring option to move a function definition from header to cpp, or vice-versa. Just right-click on the definition, choose Refactor/Move Definition Location and that’s it. Now your code looks like this. You can do the reverse too. There seems to be a bug in this CTP though – when you move … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VS14 CTP – Move Definition Location</span></a>

VS14 CTP – Create Declaration / Definition

The CTP 2 has a mostly stable implementation of the “Create Declaration / Definition” refactoring tool for your C++ projects. It lets you auto generate the definition or declaration of a member function. Example, if you have a class called Employee, declared in Employee.h and defined in Employee.cpp, you can type in a function declaration … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VS14 CTP – Create Declaration / Definition</span></a>

VS14 CTP – User-defined literals

User-defined literals is a C++ 11 feature that’s been implemented in the VS 14 CTP. Some of the standard headers have already been updated to define user defined literals. Example, <string> has an s-suffix for string literals. So you can do the following now, and both lines of code are identical. The definition in <string> … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VS14 CTP – User-defined literals</span></a>

VS14 CTP – auto return type

Instead of implementing all the C++ 11 features first and then targeting C++ 14, the VC++ team have taken an approach where they will implement both in parallel. This will allow them to implement popular C++ 14 features ahead of less popular C++ 11 features. Either way, at some point, they will have a release … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VS14 CTP – auto return type</span></a>

VS14 CTP – Inheriting constructors

Inheriting constructors is a C++ 11 feature implemented in this CTP. It extends the using declaration to allow a derived class to indicate that it needs to inherit the base class constructors. Here’s a basic example. You’ll get this error message (as of this CTP). Had Base had a default constructor or if the existing … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VS14 CTP – Inheriting constructors</span></a>

VS14 CTP – Extended sizeof

The Visual Studio 14 CTP is now available as a VM on Azure. The C++ compiler in the CTP has several enhancements for C++ 11 and C++ 14 features. C++ 11 proposes a feature to extend sizeof to apply to non-static data members without needing a temporary object. The CTP implements that feature. Consider the … <a href="" class="more-link">Continue reading <span class="screen-reader-text">VS14 CTP – Extended sizeof</span></a>

Azure queues – updating messages

The default invisibility timeout of 30 seconds may not suffice on occasions. For those situations, you can change the timeout so that you get more time to do something with your message prior to deleting it. You can also update an existing message. The code snippet below shows how that can be done. One thing … <a href="" class="more-link">Continue reading <span class="screen-reader-text">Azure queues – updating messages</span></a>

Using Azure queues from C++

Azure queues are used to store a large number of items (referred to as messages). Each message can go up to 64 Kb. A typical use for queues is intra-app communication, for example your website might add messages to the queue for a background service to process later on. The C++ Azure storage SDK maintains … <a href="" class="more-link">Continue reading <span class="screen-reader-text">Using Azure queues from C++</span></a>

Downloading blob content

I missed this in the previous blog entry. The SDK makes it really trivial to extract blob data. For text content you can directly get the text, and for non-text content you can either download to a file or to a stream. The code snippet below shows how it’s done.