我最近在 Visual Studio 2015 中创建了一个应用程序,链接如下: https://azure.microsoft.com/en-in/documentation/articles/documentdb-dotnet-application/
但是当我构建解决方案时,它显示了以下错误:
Value cannot be
null
.
Parameter name:uriString
Line 71:public static void Initialize()
Line 72:{
Line 73:client = new DocumentClient(new Uri(ConfigurationManager.AppSettings["https://<db-name>.documents.azure.com:443/"]), ConfigurationManager.AppSettings["<db-key>"]);
Line 74:CreateDatabaseIfNotExistsAsync().Wait();
Line 75:CreateCollectionIfNotExistsAsync().Wait();
Source File:
C:\Users\BHAVIN PATEL\Documents\Visual Studio 2015\Projects\documentdb-dotnet-todo-app-master\src\DocumentDBRepository.cs
Line: 73
我已将 URI 和主/辅键插入 Web.config
我的应用程序的文件来自在 Azure 中创建的 DocumentDB 应用程序。
最佳答案
我在运行 Azure Function
时收到此错误。
我正在从 Azure Key Vault
读取连接字符串值之一,并且我已在 Azure Function 配置的应用设置中设置了该值。根据Microsoft Documentation ,必须为 Azure Function 设置托管标识
,并使用创建的托管标识对象在 Key Vault 配置中创建访问策略
,以便 Azure Function 应用程序可以从 Key Vault 读取值。
我缺少此设置,因此键 ServiceBusConnectionString
的应用程序设置值始终为空,因此出现上述错误。配置访问策略后,错误消失。希望对您有所帮助。
关于asp.net - 值不能为空。参数名称: uriString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40298883/