title: Upgrading Azure Functions to 5.0 : System.UriFormatException
body: <p>I have been working on upgrading one of our Azure Functions implementations to .net 5. I have battled may demons already but just as I though I had sorted out all the config and dependency injection changes, it throws a curve ball at me. After <code>host.RunAsync</code> in <code>Main</code>, I get the following exception and I am at a bit of a loss as to the culprit. Has anyone run into and fixed this one?</p>
  <pre><code>System.UriFormatException
    HResult=0x80131537
    Message=Invalid URI: The hostname could not be parsed.
    Source=System.Private.Uri
    StackTrace:
     at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
     at Grpc.Net.Client.GrpcChannel.ForAddress(String address, GrpcChannelOptions channelOptions)
     at Microsoft.Extensions.DependencyInjection.GrpcServiceCollectionExtensions.&lt;&gt;c.&lt;AddGrpc&gt;b__1_1(IServiceProvider p) in D:\a\1\s\src\DotNetWorker.Grpc\GrpcServiceCollectionExtensions.cs:line 58
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.&lt;&gt;c__DisplayClass1_0.&lt;RealizeService&gt;b__0(ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
     at Microsoft.Extensions.Hosting.Internal.Host.&lt;StartAsync&gt;d__9.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.&lt;RunAsync&gt;d__4.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.&lt;RunAsync&gt;d__4.MoveNext()
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
     at MySoftware.FunctionApp.Program.&lt;Main&gt;(String[] args)
  
    This exception was originally thrown at this call stack:
      [External Code]
  </code></pre>
  <p>My Program.cs main looks like:</p>
  <pre><code>using Microsoft.Extensions.Hosting;
  using System.Threading.Tasks;
  
  namespace FunctionApp1
  {
      /// &lt;summary&gt;
      /// Entry
      /// &lt;/summary&gt;
      public class Program
      {
          static async Task Main(string[] args)
          {
              var host = new HostBuilder()
                  .ConfigureFunctionsWorkerDefaults()
                  .Build();
  
              await host.RunAsync();
          }
      }
  }
  </code></pre>
  <p>And my Function</p>
  <pre><code>   using Microsoft.AspNetCore.Mvc;
  using Microsoft.Azure.Functions.Worker;
  using Microsoft.Azure.Functions.Worker.Http;
  using Microsoft.Azure.WebJobs;
  using Microsoft.Azure.WebJobs.Extensions.Http;
  using Microsoft.Extensions.Logging;
  using Newtonsoft.Json;
  using System.IO;
  using System.Threading.Tasks;
  
  namespace FunctionApp1
  {
      /// &lt;summary&gt;
      /// 
      /// &lt;/summary&gt;
      public static class Function1
      {
          /// &lt;summary&gt;
          /// 
          /// &lt;/summary&gt;
          /// &lt;param name=&quot;req&quot;&gt;&lt;/param&gt;
          /// &lt;param name=&quot;ctx&quot;&gt;&lt;/param&gt;
          /// &lt;returns&gt;&lt;/returns&gt;
          [FunctionName(&quot;Function1&quot;)]
          public static async Task&lt;IActionResult&gt; Run(
              [HttpTrigger(AuthorizationLevel.Function, &quot;get&quot;, &quot;post&quot;, Route = null)] HttpRequestData req, FunctionContext ctx)
          {
              ctx.GetLogger(&quot;out&quot;).LogInformation(&quot;C# HTTP trigger function processed a request.&quot;);
  
              string name = req.ReadAsString();
  
              string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
              dynamic data = JsonConvert.DeserializeObject(requestBody);
              name = name ?? data?.name;
  
              string responseMessage = string.IsNullOrEmpty(name)
                  ? &quot;This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.&quot;
                  : $&quot;Hello, {name}. This HTTP triggered function executed successfully.&quot;;
  
              return new OkObjectResult(responseMessage);
          }
      }
  }
  </code></pre>
  <p>When I use <code>func host start</code> I also get the error &quot;No job functions found. Try making your job classes and methods public.&quot;</p>
  <pre><code>[2021-04-09T07:37:04.953Z] FUNCTIONS_WORKER_RUNTIME set to dotnet-isolated. Skipping WorkerConfig for language:python
  [2021-04-09T07:37:04.954Z] Reading functions metadata
  [2021-04-09T07:37:04.955Z] 0 functions found
  [2021-04-09T07:37:04.962Z] 0 functions loaded
  [2021-04-09T07:37:04.969Z] Generating 0 job function(s)
  [2021-04-09T07:37:04.978Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
  [2021-04-09T07:37:04.983Z] Initializing function HTTP routes
  [2021-04-09T07:37:04.985Z] No HTTP routes mapped
  [2021-04-09T07:37:04.986Z]
  [2021-04-09T07:37:04.994Z] Host initialized (53ms)
  [2021-04-09T07:37:04.997Z] Host started (63ms)
  [2021-04-09T07:37:04.998Z] Job host started
  For detailed output, run func with --verbose flag.
  </code></pre>