PULUMI -C# - 输出变量
我正在尝试通过下一类提供资源组。从堆栈类调用它,但面临输出变量的问题。
class GenerateResourceGroup
{
public GenerateResourceGroup(Input<string> location, Input<string> rgName, Dictionary<string, string> tags)
{
Console.WriteLine(location);
Console.WriteLine(rgName);
var config = new Pulumi.Config();
var resourceGroup = new Pulumi.AzureNative.Resources.ResourceGroup("resourceGroup", new Pulumi.AzureNative.Resources.ResourceGroupArgs
{
Location = location,
ResourceGroupName = rgName,
Tags = tags,
});
resourceGroupName = resourceGroup.Name;
}
[Output]
public Output<string> resourceGroupName { get; }
}
错误:即使我尝试使用应用程序,但仍会出现错误。
pulumi.input
1 [System.String] Pulumi.input
1 [System.String] 不支持[输出]上的[输出]上调用[ToString]。 为了获得输出的价值作为输出考虑: 1。O.Apply(v =&gt; $“ prefix {v}后缀”) 2。output.format($“ prefix {hostName}后缀”); 参见 https://pulumi.io.io/help/outputs 有关更多详细信息。
I am trying to provision resource group with below class. Calling it from the stack class but facing some issue with the output variable.
class GenerateResourceGroup
{
public GenerateResourceGroup(Input<string> location, Input<string> rgName, Dictionary<string, string> tags)
{
Console.WriteLine(location);
Console.WriteLine(rgName);
var config = new Pulumi.Config();
var resourceGroup = new Pulumi.AzureNative.Resources.ResourceGroup("resourceGroup", new Pulumi.AzureNative.Resources.ResourceGroupArgs
{
Location = location,
ResourceGroupName = rgName,
Tags = tags,
});
resourceGroupName = resourceGroup.Name;
}
[Output]
public Output<string> resourceGroupName { get; }
}
Error: Even I tried to utilize apply but still getting error.
Pulumi.Input
1[System.String] Pulumi.Input
1[System.String]
Calling [ToString] on an [Output] is not supported.
To get the value of an Output as an Output consider:
1. o.Apply(v => $"prefix{v}suffix")
2. Output.Format($"prefix{hostname}suffix");
See https://pulumi.io/help/outputs for more details.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是CLI的问题。我卸载了最新版本的CLI并安装了旧版本2.33.1。这解决了问题。由于API的折旧,这都是BCOZ的基础API。
It was an issue with the cli.. i uninstalled the latest version of CLI and installed old version 2.33.1. That has solved the problem. It's all bcoz underlying api due to the depreciation of the API.. learn.microsoft.com/cli/azure/microsoft-graph-migration