4

I created a C# Azure Function in Visual Studio Code. When I run the function in Visual Studio Code, I get the following error:

[8/21/2020 1:27:34 AM] A host error has occurred during startup operation '803d7235-e81a-4768-a68d-15fcd93d8518'.
[8/21/2020 1:27:34 AM] System.Private.Uri: Value cannot be null. (Parameter 'uriString').
[8/21/2020 1:27:34 AM] Stopping JobHost
Value cannot be null. (Parameter 'provider')

How can I fix it?

enter image description here

wonderful world
  • 8,704
  • 14
  • 76
  • 142
  • 1
    Does this answer your question? [Azure Function V2 Value cannot be null](https://stackoverflow.com/questions/59001071/azure-function-v2-value-cannot-be-null) – Gaurav Aug 21 '20 at 01:38
  • I changed the connection string with what I got from the Azure account. I don't see the error now. – wonderful world Aug 21 '20 at 01:42
  • If you dont have more question, you can post an answer to end this question. – Bowman Zhu Aug 21 '20 at 01:59

3 Answers3

1

This appears to be a generic issue where if any azure service cannot connect to any other service using a Uri you see this error. You seem to get it if the problem occurs prior to invocation, i.e. in Startup.cs. So check all you Uri calls have the correct url/connection string.

For me the issue was this line in my startup:

builder.AddSecretClient(new Uri(Environment.GetEnvironmentVariable("KeyVaultUrl")));

That environment variable was null.

Liam
  • 22,818
  • 25
  • 93
  • 157
1

For me the problem was that I had pasted an incorrect connection string value into local.settings.json - instead of "EndPoint=... I had "\"Endpoint=...

Peter Morris
  • 13,426
  • 8
  • 61
  • 112
0

There are couple of things you can check :

  1. If we are using any connection endpoint and reading the value from the appsettings. If yes, check the value of that settings.
  2. Please confirm whether we are using a valid service bus connection endpoint in this case. ( if there is any)

These are very generic explanation for the problem statement as that doesn't provide more details. In case of functions many a times we see this error because if the connection string value is read from Azure Key Vault and you miss out on setting this value in the app settings of Azure Function configuration. In this scenario, an Access Policy created in the Key Vault configuration so that Azure Function application can read the values from the Key Vault. So you need to reverify the access policies to make sure the app settings values of the keys have valid values.

Dharman
  • 21,838
  • 18
  • 57
  • 107