我已经在Azure Web应用程序中托管了Azure Web作业,它每小时运行一次,我需要将Web作业运行时作为键值对。下一次,当Webjob运行时,它将选择最后一个运行时并执行其操作。我正在考虑在Azure应用服务的Azure AppSettings中添加密钥值对,但是我无法修改任何代码来更新Azure AppSettings中的值。
有人能告诉我密码吗?请让我知道这是一个好的方法,或者我应该使用Azure存储容器来存储最后一批运行时值。
发布于 2019-10-18 08:28:55
但是我无法在Azure AppSettings中修改任何代码来更新这个值。
您可以使用Microsoft.WindowsAzure.Management.WebSites来实现它。
var credentials = GetCredentials(/*using certificate*/);
using (var client = new WebSiteManagementClient(credentials))
{
var currentConfig = await client.WebSites.GetConfigurationAsync(webSpaceName,
webSiteName);
var newConfig = new WebSiteUpdateConfigurationParameters
{
ConnectionStrings = null,
DefaultDocuments = null,
HandlerMappings = null,
Metadata = null,
AppSettings = currentConfig.AppSettings
};
newConfig.AppSettings[mySetting] = newValue;
await client.WebSites.UpdateConfigurationAsync(webSpaceName, webSiteName,
newConfig);
}或者使用Azure Fluent Api,请参阅此所以线。
https://stackoverflow.com/questions/58446763
复制相似问题