asp.net - 值不能为空。参数名称: uriString

标签 asp.net azure-cosmosdb

我最近在 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 时收到此错误。

enter image description here

我正在从 Azure Key Vault 读取连接字符串值之一,并且我已在 Azure Function 配置的应用设置中设置了该值。根据Microsoft Documentation ,必须为 Azure Function 设置托管标识,并使用创建的托管标识对象在 Key Vault 配置中创建访问策略,以便 Azure Function 应用程序可以从 Key Vault 读取值。

我缺少此设置,因此键 ServiceBusConnectionString 的应用程序设置值始终为空,因此出现上述错误。配置访问策略后,错误消失。希望对您有所帮助。

enter image description here

关于asp.net - 值不能为空。参数名称: uriString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40298883/

相关文章:

azure - Cosmosdb mongo 在大集合上创建索引 - 风险

asp.net - 与IE6、7、8兼容且易于定制的JQuery Lightbox?

javascript - ASP.Net Javascript 代码抛出奇怪的异常(即使有注释!)

c# - 在智能感知中找到但在编译时找不到的扩展

node.js - 请求率大

azure - 从 Azure 门户删除 Cosmos 集合中的文档

Azure 创建的 ARM 在 Azure 中无效

c# - 如何获取 Web 应用程序中的事件 session 列表?

asp.net - MVC3 ascx vs razor 页面渲染问题

azure - 获取文档时 Cosmos DB 内部错误