Getting error System.UriFormatException in Azure Function and unable to execute it

Hiral Jariwala 20 Reputation points
2023-07-11T09:17:51.0233333+00:00

Getting below error while executing Service bus trigger Azure function and unable to start Azure Function on Azure portal. Can anyone help me to resolve this issue or let me know what is causing this error?

System.UriFormatException:    

at System.Uri.CreateThis (System.Private.Uri, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)    at System.Uri..ctor (System.Private.Uri, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)    at Crawford.Fabric.Helpers.Clients.Core.Extensions+<>c__DisplayClass3_0`3.<AddApiClient>b__0 (Crawford.Fabric.Helpers.Clients.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)    at Microsoft.Extensions.Http.DefaultHttpClientFactory.CreateClient (Microsoft.Extensions.Http, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)    at Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions.AddTransientHelper (Microsoft.Extensions.Http, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)    at Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions+<>c__DisplayClass13_0`2.<AddTypedClientCore>b__0 (Microsoft.Extensions.Http, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)    at DryIoc.Microsoft.DependencyInjection.DryIocAdapter+<>c__DisplayClass3_0.<RegisterDescriptor>b__1 (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/DependencyInjection/DryIoc/DryIocAdapter.cs:169)    at DryIoc.Registrator+<>c__DisplayClass27_0.<RegisterDelegate>b__0 (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/DependencyInjection/DryIoc/Container.cs:4550)    at DryIoc.Container.DryIoc.IResolver.Resolve (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/DependencyInjection/DryIoc/Container.cs:308)    at lambda_method410 (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)    at DryIoc.Container.DryIoc.IResolver.Resolve (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/DependencyInjection/DryIoc/Container.cs:308)    at DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/DependencyInjection/DryIoc/Container.cs:208)    at DryIoc.Container.DryIoc.IResolver.Resolve (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/DependencyInjection/DryIoc/Container.cs:195)    at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedServiceProvider.GetService (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /_/src/WebJobs.Script.WebHost/DependencyInjection/ScopedServiceProvider.cs:25)    at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService (Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)    at lambda_method365 (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)    at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance (Microsoft.Azure.WebJobs.Host, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs:37)    at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance (Microsoft.Azure.WebJobs.Host, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs:32)    at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1+<>c__DisplayClass1_1.<.ctor>b__0 (Microsoft.Azure.WebJobs.Host, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs:20)    at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.Create (Microsoft.Azure.WebJobs.Host, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs:26)    at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance (Microsoft.Azure.WebJobs.Host, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:44)    at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+ParameterHelper.Initialize (Microsoft.Azure.WebJobs.Host, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:792)    at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsync>d__18.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.37.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:104)

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2023-07-11T10:30:03.43+00:00

    @Hiral Jariwala Thanks for reaching out. As per the error message indicates that there is an issue with the URI format. It seems that the URI format is not correct, and the system is unable to create a URI object. I don't see the full stack track to pinpoint the exact line number in your code. Can you please confirm if you see only the above exception trace or there is full error exception.

    I will suggest to review the application insights log to get the full exception message so it can point to the line number in your code which throws the exception. Further you can review the Diagnose and solve problems blade on your function app to know more details on the exception and the action plan if any to resolve the issue.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.