我正试图以以下方式创建sql.ServerVulnerabilityAssessment
资源:
server_vulnerability_assessment=sql.ServerVulnerabilityAssessment('sva',
storage_container_path = container_path,
storage_account_access_key = storage_account_primary_key,
resource_group_name = resource_group.name,
server_name = sql_server.name,
recurring_scans=sql.VulnerabilityAssessmentRecurringScansPropertiesArgs(
is_enabled = True,
email_subscription_admins = False,
emails = [
"<emails>" # not showing obviously
]
)
)
其中
container_path = 'https://{}.blob.core.windows.net/{}'.format(storage_account.name,storage_container.name)
我得到错误:
azure-native:sql:ServerVulnerabilityAssessment (sva):
error: autorest/azure: Service returned an error. Status=400 Code="DataSecurityInvalidUserSuppliedParameter" Message=""Invalid parameter 'storageContainerPath'. Value should be a valid blob storage container endpoint (e.g. https://MyAccount.blob.core.windows.net/containername).""
如果我对值storage_account.name
和storage_container.name
进行硬编码,它可以正常工作,没有任何错误。为什么不能在那里检索这两个属性的值?
在运行pulumi时,如果我选择显示详细信息,我会得到storageContainerPath的以下信息:
https://<pulumi.output.Output object at 0x7f1b0c8e9810>.blob.core.windows.net/<pulumi.output.Output object at 0x7f1b0c9236a0>
我做错了什么?显然,我可以对这些值进行硬编码,但为什么它不能以这种方式工作,例如sql_server.name
?
存储帐户和容器名称是Pulumi输出,这意味着在程序运行时可能还不知道它们。您需要使用Output.all
:格式化路径
container_path = Output.all(storage_account.name, storage_container.name)
.apply(lambda l: f"https://{l[0]}.blob.core.windows.net/{l[1]}")
您可以在输入和输出中找到更多的解释和示例。