Failed to load the development https certificate using docker and ocelot

Hey everyone,

I randomly started encountering the following error while using docker to host my Ocelot gateway:

Failed to load the development https certificate at ‘/root/.aspnet/https/ContentGateway.pfx’.

The solution ended up being to clean out as many temp files as possible, especially the generated certs:

  • Delete the following files: Delete the C:\Users{USER}\AppData\Roaming\ASP.NET\Https folder
  • Clean the solution. Delete the bin and obj folders (I just did this for the gateway project)
  • Restart visual studio/visual code

I’ll add an update if I can narrow down what caused the initial issue but for now this seems to work.

Thanks to the following links for the info:
https://docs.microsoft.com/en-au/aspnet/core/security/enforcing-ssl?view=aspnetcore-3.1&tabs=visual-studio#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos
https://stackoverflow.com/q/52457514/522859

eShopOnContainers – No parameterless constructor defined for type dbcontext

Hi everyone,

Another eShopOnContainers post. Today I was setting up migrations and ran into the following error:

Found DbContext ‘CatalogContext’.
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create an object of type ‘CatalogContext’. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
—> System.MissingMethodException: No parameterless constructor defined for type ‘Catalog.Api.Infrastructure.CatalogContext’.
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)

This turned out to be because I was missing the following from my CatalogContext:

public class CatalogContextDesignFactory : IDesignTimeDbContextFactory
{
public CatalogContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder()
.UseSqlServer(“Server=.;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;Integrated Security=true”);

return new CatalogContext(optionsBuilder.Options);
}
}

‘DatabaseFacade’ does not contain a definition for ‘Migrate’ and no accessible extension method ‘Migrate’… – eShopOnContainers

Hi everyone,

I’ve been going through Microsoft’s eShopOnContainers repo and replicating it as a small test project to learn microservices. While adding the WebHost Customization project I ran into the following error: 

Severity Code Description Project File Line Suppression State
Error CS1061 ‘DatabaseFacade’ does not contain a definition for ‘Migrate’ and no accessible extension method ‘Migrate’ accepting a first argument of type ‘DatabaseFacade’ could be found (are you missing a using directive or an assembly reference?) WebHost.Customization … N/A

This turned out to be a fairly simple fix. All that’s required is the following package (I installed via Nuget):

Microsoft.EntityFrameworkCore.SqlServer

Thanks to the following stackoverflow post for the info: https://stackoverflow.com/a/57606203/522859

error : “Timestamp” is not defined. – .net core and gRPC

Hi everyone,

I’m currently testing out gRPC with .NET Core and hit the following error when attempting to add a timestamp field to my proto file:

error : “Timestamp” is not defined.

My proto file was as follows:

syntax = “proto3”;
import “google/protobuf/timestamp.proto”;

option csharp_namespace = “publisher_api”;

package Weather;

// The weather forecast service definition
service Weather {

// Gets weather forecast
rpc Forecast(WeatherForecastRequest) returns (WeatherForecastResponse);
}

// The request message
message WeatherForecastRequest {

}

// The response message
message WeatherForecastResponse {
timestamp date = 1;
int32 temperatureC = 2;
int32 temperatureF = 3;
string summary = 4;
}

The solution was to fully qualify the timestamp namespace:


message WeatherForecastResponse {
google.protobuf.Timestamp date = 1;
int32 temperatureC = 2;
int32 temperatureF = 3;
string summary = 4;
}

Also ensure that you’ve added the protobuff package:

dotnet add package Google.Protobuf

See the following repo for a full example: https://github.com/Buzzology/microservicesDockerRabbitMQ

Current .NET SDK does not support targeting .NET Core 3.0 – Microservices

Hi everyone,

I’m currently learning microservices with .Net Core. As part of this I’ve been following one of Microsoft’s tutorials: https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial

It has all been pretty straight forward, however I hit an error when attempting to run docker build:

RUN dotnet restore
—> Running in 734e82e92c23
/usr/share/dotnet/sdk/2.2.207/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0. [/src/myMicroservice.csproj]
The command ‘/bin/sh -c dotnet restore’ returned a non-zero code: 1

Updating the Dockerfile references seems to have resolved the issue. I replaced each occurrence of 2.2 with 3.0 and re-ran the following command:

docker build -t microservice .

My complete docker file was as follows:

# https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial/docker-file
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY myMicroservice.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c release -o /app

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
WORKDIR /app
COPY –from=build /app .
ENTRYPOINT [“dotnet”, “myMicroservice.dll”]

Full source available here: https://github.com/Buzzology/myMicroservice