以编程方式设置Azure App Service应用程序设置/环境变量 [英] Programmatically set Azure App Service application settings / environment variables

查看:271
本文介绍了以编程方式设置Azure App Service应用程序设置/环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Azure App Service上运行的ASP.NET Core(RC1)应用程序。该应用程序从环境变量中获取其配置。我目前使用Azure Portal的应用程序设置页面来设置这些环境变量。该应用程序与Kudu一起部署(如果这是相关的)



我想通过编程方式设置这些环境变量,以便我不必经历Azure Portal每次我想要创建一个新的环境变量或修改现有的环境变量。理想情况下,我想通过调用REST API来执行此操作。这是可能的,如果是,如何?

解决方案

而不是在Azure Portal中设置环境变量,您可以部署一个appsettings .json文件与您的应用程序一起使用所需的设置。如果您有构建服务器或部署服务器,则可以使用正确的环境设置来转换配置文件。



如果您正在使用八达通部署进行部署,可以使用JSON配置变量功能来处理这个问题。



http://docs.octopusdeploy.com/display/OD/JSON+Configuration+Variables+Feature


I have an ASP.NET Core (RC1) app running on Azure App Service. The app takes its configuration from environment variables. I currently use the Azure Portal's 'Application Settings' page to set these environment variables. The app is deployed with Kudu (if this is relevant?)

I would like a way to programmatically set these environment variables so that I don't have to go through the Azure Portal every time I want to create a new environment variable or modify an existing environment variable. Ideally I would like to do this by calling a REST API. Is this possible, and if so, how?

解决方案

Instead of setting environment variables in the Azure Portal, you could deploy an appsettings.json file along with your app with the desired settings. If you have a build server or deployment server, you could transform the config file with the correct settings for your environment.

If you i.e. are using Octopus Deploy for deployments, you could use the JSON Configuration variables feature to handle this.

http://docs.octopusdeploy.com/display/OD/JSON+Configuration+Variables+Feature

这篇关于以编程方式设置Azure App Service应用程序设置/环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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