【问题标题】:Pulumi: Manipulate connection string during deploymentPulumi:在部署期间操作连接字符串
【发布时间】:2019-06-11 23:34:33
【问题描述】:

我正在使用 Pulumi 部署几个 Azure 资源,效果很好。

我正在部署一个 TopicAuthorizationRule,我需要操作连接字符串以使其与 Azure 函数触发器一起工作。

const myPolicy = new azure.eventhub.TopicAuthorizationRule(...);

const myPolicyConnectionString = myPolicy.primaryConnectionString.get();

const goodConnectionString = myPolicyConnectionString .substr(0, myPolicyConnectionString .lastIndexOf(';EntityPath'));

我有这个错误:在更新或预览期间无法调用“.get”

如何进行此字符串操作以便在 AppSettings 中进行设置?

【问题讨论】:

    标签: azure pulumi


    【解决方案1】:

    预览时连接字符串值未知,不能直接使用。它包含在 Output<T> 类型的值中,该值将在 update 时间解析。

    您可以使用apply 函数转换Output<T> 的值:

    const goodConnectionString = 
        myPolicy.primaryConnectionString.apply(s => s.substr(0, s.lastIndexOf(';EntityPath'));
    

    然后可用于分配AppSettings(无需显式调用get)。

    【讨论】:

      猜你喜欢
      • 2014-09-07
      • 1970-01-01
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-19
      • 1970-01-01
      相关资源
      最近更新 更多