Serilog configures properly when the following section. which exposes connectionString, is added to appSettings.json:

"Serilog": {
  "WriteTo": [
    {
      "Name": "AzureBlobStorage",
      "Args": {
        "connectionString": "DefaultEndpointsProtocol=https;AccountName=mystorage;AccountKey=...;EndpointSuffix=core.windows.net",
        //"connectionStringName": "MyStorageConnectionName",
        //"storageAccountUri": "https://mystorage.blob.core.windows.net",
        "storageContainerName": "myapplogs",
        "storageFileName": "MyApp {yyyy}-{MM}-{dd}.log",
        "writeInBatches": "true", // mandatory
        "period": "0.00:00:30", // mandatory
        "batchPostingLimit": "50" // optional
      }
    }, ...
  ],
}

While the above works, I have thus far been unable to replace use of the connectionString property with either connectionStringName or preferably storageAccountUri (simply leveraging Managed Identities.)

I have added the Serilog.Settings.Configuration 3.3.0 package as suggested here; and I am configuring Serilog as follows:

static void createLogger(ConfigureHostBuilder host) {
  host.UseSerilog((ctx, lc) => {
    lc.ReadFrom.Configuration(ctx.Configuration);
  });
}
1

There are 1 answers

1
G DiNunzio On

I am using a very similar configuration... I was able to get it to work with ConnectionStringName but NOT with the storageAccountUri (which would be preferable to be able to use Managed Identity)