使用门户更改 Azure 应用程序设置,无需重新启动 [英] Change an Azure App Setting using the portal without a restart

查看:20
本文介绍了使用门户更改 Azure 应用程序设置,无需重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时会这样:

在 Azure 门户中,我转到应用程序服务",然后单击我的 Web 应用程序,然后转到应用程序设置".

In the Azure portal, I go to "App Services", then I click on my web app, and then I go to "Application Settings".

这里我从应用设置"列表中更改了一个值:

Here I change one value from the "App Settings" list:

例如.我把128"改成129"

Eg. I change "128" to "129"

最后我点击保存".

这会导致我的网络应用重新启动.我不想那样.

This causes my web app to restart. I don't want that.

问题:有没有办法在不重新启动的情况下手动更改此值?如果不是,我应该以另一种方式存储这个值吗?也许在 web.config 中使用我每次都可以上传的新部分?

Question: Is there a way to manually change this value without a restart? If not, should I store this value in another way then? maybe using a new section in web.config which I can upload each time?

如果我使用新的部分,例如:

If I use a new section, eg:

<moreAppSettings configSource="moreSettings.config">
</moreAppSettings>

而这个moreSettings.config是这样的:

And this moreSettings.config is like this:

<?xml version="1.0" encoding="utf-8"?>
<moreSettings>
   <add key="ClientAppBuild" value="129" />
</moreSettings>

我可以在不重新启动的情况下上传和覆盖单个 .config 文件吗?

Can I upload and override that single .config file without a restart?

推荐答案

如果你所追求的只是一个可以在运行时修改的键值存储,为什么不使用专门设计的东西,比如 表存储Redis 缓存?

If all you're after is a key-value store that you can modify during runtime, why not use something designed specifically to do that, like Table Storage or Redis Cache?

如果您只是想存储您的内部版本号,只需在您的项目中部署一个静态 VERSION 文件(不受源代码管理跟踪)并在构建时增加内部版本号.您需要将此文件保留在 wwwroot 之外(以及在 d:homesitesomethingElse 下),以便下一次部署不会清理它.

If you're simply trying to store your build number, just deploy a static VERSION file with your project (untracked by source control) and increment the build number inside, at build time. You'll want to keep this file outside of wwwroot (and under d:homesitesomethingElse) so the next deployment won't clean it up.

如果您将源代码控制连接到 Kudu 以进行持续集成,您可以获得当前/活动的提交 id(如果您不回滚,这也代表您最新构建的提交)和一些通过调用 Kudu 的 /api/deployments 来做其他有趣的事情:

If you hook up source control to Kudu for continuous integration, you can get the current/active commit id (which also represents your latest built commit if you don't roll back) and a few other interesting things by calling Kudu's /api/deployments:

http 与 curl 类似但不同

http is like curl but different

$ http https://SiteUsername:SitePassword@sitename.scm.azurewebsites.net/api/deployments

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
...

{
    "active": true,
    "author": "snobu",
    "deployer": "GitHub",
    "end_time": "2017-03-29T08:47:08.954981Z",
    "id": "5ada48724129c78b8a993b4a25f2144aec03cbd2",
    "message": "Changed bootstrap theme to Flatly",
    ...

更多关于该 API 的信息 - https://github.com/projectkudu/kudu/wiki/REST-API#deployment

More on that API here - https://github.com/projectkudu/kudu/wiki/REST-API#deployment

这比人工构建编号更有意义.您可以安全地将 站点级凭据 存储为应用程序设置并构造 /api/deployments 没有硬编码秘密的 URL.

That's way more meaningful than an artificial build number. You can safely store the site-level credentials as Application Settings and construct the /api/deployments URL without hard coding secrets in.

这篇关于使用门户更改 Azure 应用程序设置,无需重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆