gpt4 book ai didi

azure - 应用程序设置 Azure

转载 作者:行者123 更新时间:2023-12-03 01:39:52 24 4
gpt4 key购买 nike

我是 Azure 新手,遇到以下问题:
我的 web.config 中有这个 key :
添加 key="BlobStorageConnectionString"value="xxxxxxxx"
问题是,当我将其添加到 azure 应用程序服务中的应用程序设置时,当我在日志中搜索时,我得到以下内容:
从 ServiceRuntime 获取“BlobStorageConnectionString”:失败
从 ConfigurationManager 获取“BlobStorageConnectionString”:通过。

我已经尝试了一些教程,但我仍然找不到原因。
我已经没有想法了,有什么建议吗?

最佳答案

如果您在应用程序设置中添加存储帐户字符串,它将存储为环境。因此您可以使用 Environment.GetEnvironmentVariable("storageconnectionstring") 读取它。然后解析它,代码将如下所示。

        string storageConnectionString = Environment.GetEnvironmentVariable("storageconnectionstring");

// Check whether the connection string can be parsed.
if (CloudStorageAccount.TryParse(storageConnectionString, out storageAccount))
{
try
{
// Create the CloudBlobClient that represents the Blob storage endpoint for the storage account.
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
........
........
}
}

您还可以在 WebJob 等应用中配置连接,您可以使用 JobHostConfiguration()。代码如下所示。连接名称应为AzureWebJobsStorage

   var config = new JobHostConfiguration();
config.DashboardConnectionString = "";

也可以选择使用配置类,具体可以引用这个article .

希望这可以帮助您,如果您还有其他问题,请告诉我。

关于azure - 应用程序设置 Azure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54857741/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com