使用 VSTS 和 Azure 时正确管理应用程序设置
Proper management of application settings when using VSTS and Azure
如果您使用 VSTS 和 Azure,有两种不同的方式来管理应用程序设置。请记住,这只是用于持续部署的工具示例。
您可以在 VSTS 的 CD 管道中覆盖 JSON 个文件(旧系统中的 Web 配置),或者您可以覆盖 Azure“应用程序设置”部分中的设置。我只是在想应该在哪里管理什么设置?
我的想法是在 Azure 应用程序设置部分管理依赖于数据库(连接字符串)、外部服务(例如 Application Insights)等第三方模块的设置。如果第 3 方系统中出现某些更改,这可以让您灵活地快速更改某些设置。
仅取决于我将在 VSTS 中管理的应用程序的内容。
功能切换怎么样?
假设您有一个股票市场,并且您正在构建一个管理 selling/buying 名为 Blah 的新加密货币的模块。在所有测试之后,您决定发布该功能并获取负责 enable/disable 新功能的标志。在 Azure 的 App Settings 或 VSTS 的 CD pipeline 中,你会在哪里取消标志?
也许还有更多我没有提到的其他类型的设置,哪些管理起来有问题?我问这个问题的主要原因是当应用程序增长时设置管理会出现问题,很容易导致配置文件混乱。
请告诉我在 Web 应用程序中管理应用程序设置的正确方法是什么?
您可以尝试使用扩展程序 Azure WebApp Configuration task 来管理 Web 应用程序中的应用程序设置。
The Azure WebApp Configuration task reads VSTS variables and adds
those as AppSettings and ConnectionStrings to an Azure WebApp. The
task also supports Slot Settings. The task can be linked to a
web.config to validate if all AppSettings and ConnectionStrings in the
web.config exists as VSTS variable.
您还可以参考以下文章来manage/configure应用程序设置:
就我而言,正确的方法是采用一致的方法。我个人的偏好(我相信这是我合作过的许多其他人的偏好)是在应用服务中使用应用程序设置,因此在部署任务的 "Application and Configuration Settings" 部分中的发布期间部署这些设置.
以下是我看到的在发布期间而不是构建过程中使用应用程序设置的好处:
- 设置在发布期间进行管理,因此构建工件与环境无关。这意味着您可以使用发布设置将相同的工件部署到任何环境。如果您将相同的工件部署到设置不同的灾难恢复环境,这将特别有用。
- 应用设置位于一致的位置。任何对设置进行更改的人都知道在哪里可以找到它们。
- 如果您更改了核心设置,则不必重建工件
我找到了一个非常好的现代替代方法来管理应用程序设置:Azure-Resource-Manager
The infrastructure for your application is typically made up of many
components – maybe a virtual machine, storage account, and virtual
network, or a web app, database, database server, and third-party
services. You don't see these components as separate entities, instead
you see them as related and interdependent parts of a single entity.
You want to deploy, manage, and monitor them as a group. Azure
Resource Manager enables you to work with the resources in your
solution as a group. You can deploy, update, or delete all the
resources for your solution in a single, coordinated operation. You
use a template for deployment and that template can work for different
environments such as testing, staging, and production. Resource
Manager provides security, auditing, and tagging features to help you
manage your resources after deployment.
请记住,资源可以是独立的。
我还发现亚马逊创建了非常相似的东西,叫做 CloudFormation:
AWS CloudFormation provides a common language for you to describe and
provision all the infrastructure resources in your cloud environment.
CloudFormation allows you to use a simple text file to model and
provision, in an automated and secure manner, all the resources needed
for your applications across all regions and accounts. This file
serves as the single source of truth for your cloud environment. AWS
CloudFormation is available at no additional charge, and you pay only
for the AWS resources needed to run your applications.
如果您使用 VSTS 和 Azure,有两种不同的方式来管理应用程序设置。请记住,这只是用于持续部署的工具示例。
您可以在 VSTS 的 CD 管道中覆盖 JSON 个文件(旧系统中的 Web 配置),或者您可以覆盖 Azure“应用程序设置”部分中的设置。我只是在想应该在哪里管理什么设置? 我的想法是在 Azure 应用程序设置部分管理依赖于数据库(连接字符串)、外部服务(例如 Application Insights)等第三方模块的设置。如果第 3 方系统中出现某些更改,这可以让您灵活地快速更改某些设置。
仅取决于我将在 VSTS 中管理的应用程序的内容。 功能切换怎么样? 假设您有一个股票市场,并且您正在构建一个管理 selling/buying 名为 Blah 的新加密货币的模块。在所有测试之后,您决定发布该功能并获取负责 enable/disable 新功能的标志。在 Azure 的 App Settings 或 VSTS 的 CD pipeline 中,你会在哪里取消标志?
也许还有更多我没有提到的其他类型的设置,哪些管理起来有问题?我问这个问题的主要原因是当应用程序增长时设置管理会出现问题,很容易导致配置文件混乱。 请告诉我在 Web 应用程序中管理应用程序设置的正确方法是什么?
您可以尝试使用扩展程序 Azure WebApp Configuration task 来管理 Web 应用程序中的应用程序设置。
The Azure WebApp Configuration task reads VSTS variables and adds those as AppSettings and ConnectionStrings to an Azure WebApp. The task also supports Slot Settings. The task can be linked to a web.config to validate if all AppSettings and ConnectionStrings in the web.config exists as VSTS variable.
您还可以参考以下文章来manage/configure应用程序设置:
就我而言,正确的方法是采用一致的方法。我个人的偏好(我相信这是我合作过的许多其他人的偏好)是在应用服务中使用应用程序设置,因此在部署任务的 "Application and Configuration Settings" 部分中的发布期间部署这些设置.
以下是我看到的在发布期间而不是构建过程中使用应用程序设置的好处:
- 设置在发布期间进行管理,因此构建工件与环境无关。这意味着您可以使用发布设置将相同的工件部署到任何环境。如果您将相同的工件部署到设置不同的灾难恢复环境,这将特别有用。
- 应用设置位于一致的位置。任何对设置进行更改的人都知道在哪里可以找到它们。
- 如果您更改了核心设置,则不必重建工件
我找到了一个非常好的现代替代方法来管理应用程序设置:Azure-Resource-Manager
The infrastructure for your application is typically made up of many components – maybe a virtual machine, storage account, and virtual network, or a web app, database, database server, and third-party services. You don't see these components as separate entities, instead you see them as related and interdependent parts of a single entity. You want to deploy, manage, and monitor them as a group. Azure Resource Manager enables you to work with the resources in your solution as a group. You can deploy, update, or delete all the resources for your solution in a single, coordinated operation. You use a template for deployment and that template can work for different environments such as testing, staging, and production. Resource Manager provides security, auditing, and tagging features to help you manage your resources after deployment.
请记住,资源可以是独立的。 我还发现亚马逊创建了非常相似的东西,叫做 CloudFormation:
AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment. CloudFormation allows you to use a simple text file to model and provision, in an automated and secure manner, all the resources needed for your applications across all regions and accounts. This file serves as the single source of truth for your cloud environment. AWS CloudFormation is available at no additional charge, and you pay only for the AWS resources needed to run your applications.