NET 5.0 WebJob only wants to write to my local Blob storage

416 Views Asked by At

We're halfway through 2021 and all the WebJob answers I'm finding are pretty old.. maybe there's a new wrinkle I'm missing

This picture from my Microsoft Azure Storage Explorer says it all:

enter image description here

On my machnine, I use this appsettings.Development.json file -- allowing my dotnet console to talk with my Azurite storage instance (Azurite is running from my local Docker)

{
  "ConnectionStrings": {
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",

    "ContosoData": "Initial Catalog=Contoso;Integrated Security=True;Encrypt=False;Data Source=(localdb)\\MSSQLLocalDB;"
  }
}

In production, these lines from Program.cs will override the above with my 'real' connection strings...

.ConfigureAppConfiguration((hostingContext, conf) =>
{

    var env = hostingContext.HostingEnvironment;

    _configuration = conf
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
        .AddEnvironmentVariables()
        .Build();
})

... which I've saved into my Web App Service's Configuration page: enter image description here

The singular method in my Functions.cs is successfully detected and called - I'm using this output attribute to write to the Blob storage

public class Functions
{
    [Singleton]
    public async static Task CopyDates(
        [TimerTrigger("0 */5 * * * *", RunOnStartup = true)] TimerInfo myTimer, 
        [Blob("tsl-updater-logs/log.txt", FileAccess.Write)] TextWriter logger)
    {

        logger.WriteLine($"C# Timer trigger function executed at: {DateTime.Now}");
    }
}

Because the function is marked with RunOnStartup = true my dashboard soon shows the job to be Started or Running after I publish the job - but I never see the log.txt file get written into my Blob storage container

What am I missing?

Oh.. if you must know.. these are my nugets:

enter image description here

UPDATE:

Adding: Full source of my Program.cs

using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.Azure.WebJobs.Host;

 class Program
    {
        public static IConfiguration _configuration;
        public static IServiceCollection _services;

        static async Task Main(string[] args)
        {
            var builder = new HostBuilder();

            builder
                //.UseEnvironment("Development")
                .ConfigureWebJobs(b =>
                {
                    b.AddAzureStorageCoreServices();
                    b.AddAzureStorageBlobs();
                    b.AddTimers();
                    //b.AddDashboardLogging();

                })
                .ConfigureAppConfiguration((hostingContext, conf) =>
                {

                    var env = hostingContext.HostingEnvironment;

                    _configuration = conf
                        .SetBasePath(env.ContentRootPath)
                        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
                        .AddEnvironmentVariables()
                        .Build();
                })
                .ConfigureLogging((context, b) =>
                {
                    b.SetMinimumLevel(LogLevel.Information);
                    b.AddConsole();
                })
                .ConfigureServices(svc =>
                {
                    svc.AddDbContext<Models.DataWareHouseCtx>(opt =>
                        opt.UseSqlServer(_configuration.GetConnectionString("DataWareHouse"))
                            .EnableSensitiveDataLogging(true)
                            .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking));

                    svc.AddDbContext<Models.TslDataContext>(opt =>
                        opt.UseSqlServer(_configuration.GetConnectionString("ThingStatusLocation"))
                            .EnableSensitiveDataLogging(true)
                            .UseQueryTrackingBehavior(QueryTrackingBehavior.TrackAll));

                    _services = svc;

                });
                //.UseConsoleLifetime();


            var host = builder.Build();

            
            using (host)
            {
                await host.RunAsync();
            }
        }

 
    }

UPDATE 2:

Output of log dashboard

[07/13/2021 20:53:10 > ef3fc6: SYS INFO] Status changed to Stopped
[07/13/2021 21:24:12 > ef3fc6: SYS INFO] Detected WebJob file/s were updated, refreshing WebJob
[07/13/2021 21:24:12 > ef3fc6: SYS INFO] Status changed to Starting
[07/13/2021 21:24:12 > ef3fc6: SYS INFO] WebJob singleton setting is False
[07/13/2021 21:24:13 > ef3fc6: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[07/13/2021 21:24:13 > ef3fc6: SYS INFO] Status changed to Running
[07/13/2021 21:24:13 > ef3fc6: INFO] 
[07/13/2021 21:24:13 > ef3fc6: INFO] D:\local\Temp\jobs\continuous\My.WebJob.Updater\s02hk5ti.50s>dotnet My.WebJob.Updater.dll  
[07/13/2021 21:24:14 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Config.BlobsExtensionConfigProvider[0]
[07/13/2021 21:24:14 > ef3fc6: INFO]       registered http endpoint = 
[07/13/2021 21:24:14 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:24:14 > ef3fc6: INFO]       LoggerFilterOptions
[07/13/2021 21:24:14 > ef3fc6: INFO]       {
[07/13/2021 21:24:14 > ef3fc6: INFO]         "MinLevel": "Information",
[07/13/2021 21:24:14 > ef3fc6: INFO]         "Rules": []
[07/13/2021 21:24:14 > ef3fc6: INFO]       }
[07/13/2021 21:24:14 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:24:14 > ef3fc6: INFO]       FunctionResultAggregatorOptions
[07/13/2021 21:24:14 > ef3fc6: INFO]       {
[07/13/2021 21:24:14 > ef3fc6: INFO]         "BatchSize": 1000,
[07/13/2021 21:24:14 > ef3fc6: INFO]         "FlushTimeout": "00:00:30",
[07/13/2021 21:24:14 > ef3fc6: INFO]         "IsEnabled": true
[07/13/2021 21:24:14 > ef3fc6: INFO]       }
[07/13/2021 21:24:14 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:24:14 > ef3fc6: INFO]       QueuesOptions
[07/13/2021 21:24:15 > ef3fc6: INFO]       {
[07/13/2021 21:24:15 > ef3fc6: INFO]         "BatchSize": 16,
[07/13/2021 21:24:15 > ef3fc6: INFO]         "NewBatchThreshold": 16,
[07/13/2021 21:24:15 > ef3fc6: INFO]         "MaxPollingInterval": "00:01:00",
[07/13/2021 21:24:15 > ef3fc6: INFO]         "MaxDequeueCount": 5,
[07/13/2021 21:24:15 > ef3fc6: INFO]         "VisibilityTimeout": "00:00:00",
[07/13/2021 21:24:15 > ef3fc6: INFO]         "MessageEncoding": "Base64"
[07/13/2021 21:24:15 > ef3fc6: INFO]       }
[07/13/2021 21:24:15 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:24:15 > ef3fc6: INFO]       SingletonOptions
[07/13/2021 21:24:15 > ef3fc6: INFO]       {
[07/13/2021 21:24:15 > ef3fc6: INFO]         "LockPeriod": "00:00:15",
[07/13/2021 21:24:15 > ef3fc6: INFO]         "ListenerLockPeriod": "00:01:00",
[07/13/2021 21:24:15 > ef3fc6: INFO]         "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[07/13/2021 21:24:15 > ef3fc6: INFO]         "LockAcquisitionPollingInterval": "00:00:05",
[07/13/2021 21:24:15 > ef3fc6: INFO]         "ListenerLockRecoveryPollingInterval": "00:01:00"
[07/13/2021 21:24:15 > ef3fc6: INFO]       }
[07/13/2021 21:24:15 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:24:15 > ef3fc6: INFO]       BlobsOptions
[07/13/2021 21:24:15 > ef3fc6: INFO]       {
[07/13/2021 21:24:15 > ef3fc6: INFO]         "MaxDegreeOfParallelism": 16
[07/13/2021 21:24:15 > ef3fc6: INFO]       }
[07/13/2021 21:24:15 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.JobHostService[0]
[07/13/2021 21:24:15 > ef3fc6: INFO]       Starting JobHost
[07/13/2021 21:24:15 > ef3fc6: INFO] info: Host.Startup[0]
[07/13/2021 21:24:15 > ef3fc6: INFO]       Found the following functions:
[07/13/2021 21:24:15 > ef3fc6: INFO]       Ross.WebJob.Tsl.Updater.Functions.CopyDates
[07/13/2021 21:24:15 > ef3fc6: INFO]       
[07/13/2021 21:24:15 > ef3fc6: INFO] info: Host.Startup[0]
[07/13/2021 21:24:15 > ef3fc6: INFO]       Job host started
[07/13/2021 21:24:15 > ef3fc6: INFO] Application started. Press Ctrl+C to shut down.
[07/13/2021 21:24:15 > ef3fc6: INFO] Hosting environment: Production
[07/13/2021 21:24:15 > ef3fc6: INFO] Content root path: D:\local\Temp\jobs\continuous\My.WebJob.Updater\s02hk5ti.50s\
[07/13/2021 21:34:22 > ef3fc6: SYS INFO] Detected WebJob file/s were updated, refreshing WebJob
[07/13/2021 21:34:22 > ef3fc6: SYS INFO] Status changed to Stopping
[07/13/2021 21:34:27 > ef3fc6: ERR ] Thread was being aborted.
[07/13/2021 21:34:27 > ef3fc6: SYS INFO] WebJob process was aborted
[07/13/2021 21:34:27 > ef3fc6: SYS INFO] Status changed to Stopped
[07/13/2021 21:34:28 > ef3fc6: SYS INFO] Status changed to Starting
[07/13/2021 21:34:28 > ef3fc6: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[07/13/2021 21:34:28 > ef3fc6: SYS INFO] Status changed to Running
[07/13/2021 21:34:28 > ef3fc6: INFO] 
[07/13/2021 21:34:28 > ef3fc6: INFO] D:\local\Temp\jobs\continuous\My.WebJob.Tsl.Updater\s02hk5ti.50s>dotnet Ross.WebJob.Tsl.Updater.dll  
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Config.BlobsExtensionConfigProvider[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       registered http endpoint = 
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       LoggerFilterOptions
[07/13/2021 21:34:29 > ef3fc6: INFO]       {
[07/13/2021 21:34:29 > ef3fc6: INFO]         "MinLevel": "Information",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "Rules": []
[07/13/2021 21:34:29 > ef3fc6: INFO]       }
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       FunctionResultAggregatorOptions
[07/13/2021 21:34:29 > ef3fc6: INFO]       {
[07/13/2021 21:34:29 > ef3fc6: INFO]         "BatchSize": 1000,
[07/13/2021 21:34:29 > ef3fc6: INFO]         "FlushTimeout": "00:00:30",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "IsEnabled": true
[07/13/2021 21:34:29 > ef3fc6: INFO]       }
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       QueuesOptions
[07/13/2021 21:34:29 > ef3fc6: INFO]       {
[07/13/2021 21:34:29 > ef3fc6: INFO]         "BatchSize": 16,
[07/13/2021 21:34:29 > ef3fc6: INFO]         "NewBatchThreshold": 16,
[07/13/2021 21:34:29 > ef3fc6: INFO]         "MaxPollingInterval": "00:01:00",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "MaxDequeueCount": 5,
[07/13/2021 21:34:29 > ef3fc6: INFO]         "VisibilityTimeout": "00:00:00",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "MessageEncoding": "Base64"
[07/13/2021 21:34:29 > ef3fc6: INFO]       }
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       SingletonOptions
[07/13/2021 21:34:29 > ef3fc6: INFO]       {
[07/13/2021 21:34:29 > ef3fc6: INFO]         "LockPeriod": "00:00:15",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "ListenerLockPeriod": "00:01:00",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "LockAcquisitionPollingInterval": "00:00:05",
[07/13/2021 21:34:29 > ef3fc6: INFO]         "ListenerLockRecoveryPollingInterval": "00:01:00"
[07/13/2021 21:34:29 > ef3fc6: INFO]       }
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.OptionsLoggingService[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       BlobsOptions
[07/13/2021 21:34:29 > ef3fc6: INFO]       {
[07/13/2021 21:34:29 > ef3fc6: INFO]         "MaxDegreeOfParallelism": 16
[07/13/2021 21:34:29 > ef3fc6: INFO]       }
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Microsoft.Azure.WebJobs.Hosting.JobHostService[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       Starting JobHost
[07/13/2021 21:34:29 > ef3fc6: INFO] info: Host.Startup[0]
[07/13/2021 21:34:29 > ef3fc6: INFO]       Found the following functions:
[07/13/2021 21:34:29 > ef3fc6: INFO]       My.WebJob.Updater.Functions.CopyDates
[07/13/2021 21:34:29 > ef3fc6: INFO]       
[07/13/2021 21:34:30 > ef3fc6: INFO] info: Host.Startup[0]
[07/13/2021 21:34:30 > ef3fc6: INFO]       Job host started
[07/13/2021 21:34:30 > ef3fc6: INFO] Application started. Press Ctrl+C to shut down.
[07/13/2021 21:34:30 > ef3fc6: INFO] Hosting environment: Production
[07/13/2021 21:34:30 > ef3fc6: INFO] Content root path: D:\local\Temp\jobs\continuous\My.WebJob.Updater\s02hk5ti.50s\
[07/13/2021 22:34:28 > ef3fc6: SYS INFO] WebJob is still running
[07/14/2021 10:34:28 > ef3fc6: SYS INFO] WebJob is still running

Update 3: Finally onto something - TLS Version Not Supported

Snippet from Output pane in VS when I choose to View Streaming Logs

Application:Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
Application:   at System.Net.HttpWebRequest.GetResponse()
Application:   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
Application:   --- End of inner exception stack trace ---
Application:   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
Application:   at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadBlockList(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
Application:   at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.AppendStreamToBlob(Stream stream)
Application:   at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.ConsumeBuffer()
Application:Request Information
Application:RequestID:6bbeae68-701e-009c-0ad8-787fc9000000
Application:RequestDate:Wed, 14 Jul 2021 17:46:01 GMT
Application:StatusMessage:The TLS version of the connection is not permitted on this storage account.
Application:ErrorCode:TlsVersionNotPermitted
1

There are 1 best solutions below

0
bkwdesign On

There may've been multiple problems I was fighting, but, I finally conquered. Here's the things I did to resolve my woes:

1.) I needed to put AzureWebJobsStorage key-value into my Application Settings (perhaps former iterations of webjobs would get it from Connection Strings - but no longer)

2.) I was using some 5.0.0 beta NuGet packages that were probably failing on #1, so when I rolled them wayyyy back. (Especially Microsoft.Azure.WebJobs.Extensions.Storage - which I rolled back to 3.x.x - which is when I started getting the TLS version errors shown in my logs. The 4.0.4 is stable and happy)

Here's my current state of NuGet:
enter image description here