【发布时间】:2018-10-30 18:35:14
【问题描述】:
我正在使用共享层将我的 .NET Core Web 应用程序部署到 Azure。
下面是我的 app.config 文件,
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="SASToken" value="" />
<add key="StorageAccountPrimaryUri" value="" />
<add key="StorageAccountSecondaryUri" value="" />
</appSettings>
</configuration>
在 Azure 门户上的应用程序设置下,我更新了以下内容,
但是,当我访问我的 API 时,我收到 Http 500 错误,并显示以下异常详细信息,
System.ArgumentException: The argument must not be empty string.
Parameter name: sasToken
at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.AssertNotNullOrEmpty(String paramName, String value)
at Microsoft.WindowsAzure.Storage.Auth.StorageCredentials..ctor(String sasToken)
at ProfileVariable.DataAccessor.AzureTableStorageAccount.TableStorageAccount.ConfigureAzureStorageAccount() in C:\Users\sranade\Source\Repos\ProfileVariableService\ProfileVariable.DataAccessor\AzureTableStorageAccount\TableStorageAccount.cs:line 22
【问题讨论】:
-
这是 .NET Framework 还是 .NET Core 应用程序?您如何在代码中访问此值?
-
这是一个 .NET Core 应用程序。
var storageCred = new StorageCredentials(ConfigurationManager.AppSettings["SASToken"]);这就是我访问代码中值的方式。 -
我相信门户应用程序设置会更新(在运行时)
appsettings.json,但不会更新任何app.config值。 -
在发布到 azure 之前,您应该将
ConfigurationManager.AppSettings["SASToken"]更改为使用:Environment.GetEnvironmentVariable("SASToken",EnvironmentVariableTarget.Process)。 -
@Sameer 如果我的解决方案不起作用,请随意询问,否则您可以接受它来结束您的问题吗?
标签: c# azure azure-web-app-service azure-api-apps