azure-functions-dotnet-worker: The gRPC channel URI 'http://:' could not be parsed.

Azure function worked yesterday with zero issues. I made a small change to add a new model field to my function code, published, and now I only get this exception.

Investigative information

Please provide the following:

  • Timestamp: 2023-11-17T20:28:24Z
  • Function App version: ~4
  • Function App name: SCMessageProcessor
  • Function name(s) (as appropriate): Function1
  • Invocation ID: 4f17817d-021f-4a78-b5c8-b5b3732118c0
  • Region: South Central US

Works fine when running locally but not after any publish. Worked yesterday

Repro steps

I replay a message from my queue and I see the invocation error in the logs.

Expected behavior

When a new message is queued, the function should invoke without error and process the message like it did yesterday.

Actual behavior

https://gist.github.com/wheelie33/10625a57637aca4de1ba9da219f63404

Related information

host.json:

{
    "version": "2.0",
  "logging": {
    "logLevel": { "default": "Information" },
    "fileLoggingMode": "always",
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "enableLiveMetricsFilters": true
    }
  }
}

program.cs

using AzureMessageFunctionsEf.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;


using var loggerFactory = LoggerFactory.Create(builder =>
{
    builder.AddConsole();
});

var logger = loggerFactory.CreateLogger<Program>();


try
{
    var config = new ConfigurationBuilder()
            .AddJsonFile("local.settings.json", optional: true)
            .AddEnvironmentVariables()
            .Build();


    var connString = config.GetConnectionString("Default");

   

    var host = new HostBuilder()
        .ConfigureAppConfiguration(builder => {
            builder.AddEnvironmentVariables();
            builder.AddJsonFile("local.settings.json", optional: true);


        })
            .ConfigureServices(services =>
            {

                services.AddDbContext<DatabaseContext>(options => options.UseSqlServer(connString, options =>
                {
                    options.EnableRetryOnFailure();
                }));
            })
        .ConfigureFunctionsWorkerDefaults()
        .Build();

    await host.RunAsync();
}
catch(Exception ex)
{
    logger.LogCritical("JW: " + ex.Message);
}

Packages:

<ItemGroup>
    <PackageReference Include="Azure.Communication.Email" Version="1.0.1" />
    <PackageReference Include="Azure.Communication.Sms" Version="1.0.1" />
    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.17.0" />
    <PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.14.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
  </ItemGroup>
  <ItemGroup>

Azure Configuration

[
  {
    "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
    "value": "InstrumentationKey=06acf3bf-efda-4b61-ba72-760374208516;IngestionEndpoint=https://southcentralus-3.in.applicationinsights.azure.com/;LiveEndpoint=https://southcentralus.livediagnostics.monitor.azure.com/",
    "slotSetting": false
  },
  {
    "name": "AzureWebJobs.Function1.Disabled",
    "value": "0",
    "slotSetting": false
  },
  {
    "name": "AzureWebJobsStorage",
    "value": "DefaultEndpointsProtocol=https;AccountName=scmessageworkerfunctions;AccountKey={REDACTED};EndpointSuffix=core.windows.net",
    "slotSetting": false
  },
  {
    "name": "BlobConnectionString",
    "value": "DefaultEndpointsProtocol=https;AccountName=scoutconnectstore;AccountKey={REDACTED};EndpointSuffix=core.windows.net",
    "slotSetting": false
  },
  {
    "name": "CommunicationConnectionString",
    "value": "endpoint=https://sc-production-comm-service.unitedstates.communication.azure.com/;accesskey={REDACTED}",
    "slotSetting": false
  },
  {
    "name": "FromEmail",
    "value": "{REDACTED}",
    "slotSetting": false
  },
  {
    "name": "FromNumber",
    "value": "{REDACTED}",
    "slotSetting": false
  },
  {
    "name": "FUNCTIONS_EXTENSION_VERSION",
    "value": "~4",
    "slotSetting": false
  },
  {
    "name": "FUNCTIONS_WORKER_RUNTIME",
    "value": "dotnet-isolated",
    "slotSetting": false
  },
  {
    "name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
    "value": "0",
    "slotSetting": false
  },
  {
    "name": "ServiceBusConnectionString",
    "value": "Endpoint=sb://scoutconnect.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey={REDACTED}",
    "slotSetting": false
  },
  {
    "name": "WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED",
    "value": "1",
    "slotSetting": false
  }
]```

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 45 (3 by maintainers)

Most upvoted comments

+1 getting this issue when running locally

This is not resolved at all, no proper solution and no fix. Azure Functions got really BS…

I’m getting the same error message with my solution running locally (I haven’t gotten to deploying yet). .Net 8 isolated model.

host.Run()

is throwing

System.InvalidOperationException: "The gRPC channel URI 'http://:' could not be parsed."

I’ll post my solution here in case anyone stumble on this looking for answers. I was having an issue with including IConfiguration as a service, effectively overwriting the default Config dependency injection. This didn’t seem to be a problem before doing an upgrade to NET 8.

I moved the config import of “local.settings.json” from within ConfigureServices to ConfigureAppConfiguration where it should ideally add on to the config instead of overwriting. That got me past the gRPC error.

Before

var configuration = new ConfigurationBuilder()
              .SetBasePath(Directory.GetCurrentDirectory())
              .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
              .Build();

var host = new HostBuilder()
    .ConfigureFunctionsWebApplication()
    .ConfigureServices(s =>
    {
        s.AddSingleton<IConfiguration>(configuration);
        s.AddScoped<ITestService, TestService>();
    }) ...

After

var configuration = new ConfigurationBuilder()
              .SetBasePath(Directory.GetCurrentDirectory())
              .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
              .Build();

var host = new HostBuilder()
    .ConfigureFunctionsWebApplication()
    .ConfigureServices(s =>
    {
        s.AddScoped<ITestService, TestService>();
    })
    .ConfigureAppConfiguration(s => s.AddConfiguration(configuration))
    .Build();

The problem seems to be in the config file of the DependencyInjection project. It looks like the expected keys don’t exist or don’t have a value.

bug_dependency_injection

This is not really a fix but may be a workaround to help other get by, I had the same issue after installing .NET 8 core along side of Visual Studio 2022 to allow us to migrate our Azure functions from .NET 7 isolated to .NET 8 isolated. Uninstalling and reinstalling did not help and it even broke the .NET 7 function app . I was finally able to get .NET 7 working again by adding .NET Framework 4.8.1. development tools in Visual Studio. After installing, .NET 7 was working again but .NET 8 through the error, “There is no Functions runtime available that matches the version specified in the project” even though .NET 8 was still installed. To solve this issue and get .NET 8 working, I had to go to Tools -> Options -> Projects & Solutions -> Azure functions. Then check for updates and install updates.

I have the same issue running from Visual Studio, but if I run it via func start --dotnet-isolated from the command line then it works. Makes it difficult to debug obviously, but I can at least get around it for now.

Update: the problem on my side was that somehow azure development tools had been uninstalled from visual studio, re-installing it and doing what @rohncarlson suggested fixed it for me.

This was driving me crazy. I had intermittent problems of the program not starting - getting stuck when reading the config. And then had this issue with grpc. Removing the ConfigurationBuilder has solved the problem completely and I have verified that the HostBuilder does read the local.setting.json.

-var configuration = new ConfigurationBuilder()
-    .SetBasePath(AppContext.BaseDirectory)
-    .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
-    .AddEnvironmentVariables()
-    .Build();
var host = new HostBuilder()
    .ConfigureFunctionsWebApplication()
    .ConfigureServices(services =>
    {
        services.AddLogging();
-        services.AddSingleton<IConfiguration>(configuration);_
        services.AddApplicationInsightsTelemetryWorkerService();
        services.ConfigureFunctionsApplicationInsights();
        services.ConfigureMdbLoaderServices();
    })
    .Build();

I got the same error, this is not fixed.

I was having the exact same problem with pretty much identical settings and packages. I updated Microsoft.Azure.Functions.Worker.Sdk from 1.6.2 to 1.6.3 and that maybe was the fix that worked for me. 1.6.3 is broken when using Xunit as described here: https://github.com/Azure/azure-functions-dotnet-worker/issues/2114

1.6.4-preview1 is what I ended up with for now.

Could be a coincidence since i did a few other things as well but worth a try

EDIT. Still getting that same error at times, so this doesn’t fix it.

I had the same problem (debugging locally) and read this thread with dread. Then i closed the solution, removed all bin and debug folders and restarted. A default tactic that i always use when reaching the end of communications like these. This solved my problem so i continued working, with yet another uncomfortable feeling added to the dark cloud that hangs over me.

Even though the problem is already closed I would like to add my solution because although I had tried all the solutions proposed in this thread I had not obtained any positive results, taking a long time to solve by myself.

In my case, the function app v4 was to run as an isolated process as a Docker linux-x64 container (in debug with VS22 it was started without errors).

What I was doing wrong was the sdk image I was using in the DockerFile, I was using: FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated7.0 instead of: FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated7.0-appservice

If you need to launch the function app locally instead, you must install Azure Functions Core Tools, then publish the function app and run the following command in the publish folder: func start --dotnet-isolated

Faccio presente che è meglio specificare anche queste variabili d’ambiente:

ENV FUNCTIONS_WORKER_RUNTIME=dotnet-isolated \
 WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED=0 \
 linuxFxVersion=DOTNET-ISOLATED|7.0

I hope this helps other people.

We are facing the same issue, and we are consulting with our Microsoft sponsor. Currently, we have opted to directly remove the ‘WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED’ environment variable, in addition to the configuration changes mentioned in this same thread. With that, the error is reduced but sporadically, we still see the error in Application Insights without deploying or making modifications. We are going to try escalating the issue because it is causing us message losses and consequent loss of transactions (lost money). If we continue to experience the inconvenience, we may consider switching cloud service providers.

Hello. Another use case I ran into: Trying to write an integration test and running the code from the test methods. This shouldn’t be closed.

I have info on my issue here

https://stackoverflow.com/questions/77837962/i-am-getting-an-error-when-attempting-to-start-my-azure-function-app-net-8-iso/77838423

I seem to have narrowed it down to adding the configuration (IConfiguration) as a Singleton…

it still doesn’t work for us - do you have updates? @kshyju we did

  • WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED = 0
  • .worker to 1.20.1

Any updates on this?

We’re currently investigating the issue. In the meantime, if you are experiencing this issue only in Azure, please add/update the below app setting entry under Settings -> Environment variables -> App settings

Name

WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED

Value

0

Changing that value from 1 (it’s default) to 0 seems to have made it work. Thank you.