章鱼Web.config转换为客户端端点地址

ond*_*vic 2 web-config octopus-deploy web.config-transform

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

我在“章鱼变量”部分找到了以下内容,但似乎找不到像平时一样如何使用和实际变量解决更改的任何参考

我正在使用用于章鱼的webui

http:// {服务器名称} / app#/ projects / {项目名称} /变量

可变替代句法

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

<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
Run Code Online (Sandbox Code Playgroud)

使用章鱼变量是否有可能做到这一点?(我知道可以使用常规的Web.config转换来完成此操作,因为我们已经这样做了)。

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

端点地址

是,我将如何针对多个不同的端点地址完成此操作?

小智 6

听起来像您到了那里。如果它已经在您的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>
Run Code Online (Sandbox Code Playgroud)

当然,这里有很多选择。

对于文件名,您可以使用默认约定“ 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)。

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

希望能有所帮助。