【问题标题】:Octopus Web.config transforms for client endpoint addressOctopus Web.config 转换客户端端点地址
【发布时间】:2017-03-27 18:57:10
【问题描述】:

我有一个 Web 项目,它使用了位于客户端下的 Web.config 文件中的两个服务端点 --> 端点 --> 地址部分

我在 Octopus 变量部分找到了以下内容,但似乎找不到任何关于如何使用实际变量来解决更改的参考,就像你通常会做的那样

我正在使用八达通的 webui,这将是

http://{server-name}/app#/projects/{project-name}/variables

variable-substitution-syntax

我尝试像这样分配变量,但值从未更新 原始条目如下所示

<endpoint address="http://services-test.example.com/test.svc/soap" binding="basicHttpBinding" bindingConfiguration="soap" contract="test.service" name="soap" />

Name                    Address                         Instance   
Endpoint[A].Address     test-service-a.example.com      1
Endpoint[B].Address     test-service-b.example.com      2

这是否可以使用 Octopus 变量实现? (我知道可以使用常规的 Web.config 转换来完成,因为我们已经这样做了)。

如果可能的话,正确的替换值是多少

端点地址

对于多个不同的端点地址,我将如何实现这一点?

【问题讨论】:

    标签: web-config octopus-deploy web.config-transform


    【解决方案1】:

    听起来你是大部分的路。如果它已经在使用您的 Web.config 转换,那么您需要做的就是用变量替换令牌替换转换中的值。

    例如:Web.Release.Config

    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <system.serviceModel>
        <client>
          <endpoint address="http://#{Server1}/test.svc/soap" name="x1"
                    xdt:Locator="Match(name)" xdt:Transform="SetAttributes(address)" />
          <endpoint address="#{Endpoint2}" name="x2"
                    xdt:Locator="Match(name)" xdt:Transform="SetAttributes(address)" />
        </client>
      </system.serviceModel>
    </configuration>
    

    当然这里有很多选择。

    对于文件名,您可以坚持使用默认约定“Web.Release.config”或使用“Web.[Environment].config”或自定义。我们使用“Web.Octopus.Config”,这样它就不会被任何其他进程拾取。

    更多关于命名转换的信息:https://octopus.com/docs/deploying-applications/configuration-files#Configurationfiles-Namingconfigurationtransformfiles

    更多关于自定义转换 (Web.Octopus.com) 的信息:https://octopus.com/docs/deploying-applications/configuration-files#Configurationfiles-AdditionalConfigurationTransforms

    对于变量,您可以只为服务器定义一个变量 (name=x1),这更简单,或者只是将整个地址放在一个变量中,从而为 Octopus 提供更多控制权 (name=x2)。

    关键部分是将变量替换标记放入配置中。 Octopus 首先在配置文件上运行变量替换,然后运行转换。这意味着第一遍将替换您的 Web.Release.Config 中的令牌,然后 Octopus 将针对 Web.config 运行转换

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-30
      • 2011-07-03
      • 2011-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多