https://pulumi.com logo
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
dotnet
  • p

    purple-train-14007

    04/01/2021, 6:06 PM
    So can someone help me understand how to reference values in a stack config? I'm rather confused how dotnet gets these values from Pulumi. As an example Im trying to reference an Address prefic Ive set in the config.
  • p

    purple-train-14007

    04/01/2021, 6:07 PM
    Untitled
    b
    • 2
    • 3
  • p

    purple-train-14007

    04/02/2021, 5:36 PM
    Hello, whats the difference between Pulumi.Azure and Pulumi.AzureNative?
    t
    • 2
    • 3
  • p

    purple-train-14007

    04/02/2021, 5:38 PM
    Im starting to get the feeling the docs may be out of date as I cant find Pulumi.Azure anywhere however its referenced in the docs a lot
  • p

    prehistoric-coat-10166

    04/02/2021, 5:41 PM
    I think the
    Pulumi.Azure
    documentation can be found under "Classic providers" https://www.pulumi.com/docs/reference/pkg/azure/
  • p

    purple-train-14007

    04/02/2021, 5:42 PM
    Ah, thanks.
  • p

    purple-train-14007

    04/02/2021, 5:43 PM
    Is there a specific reason that the Azure VirtualNetwork is in Azure native while Azure Subnet is in the classic? Im assuming this is a work in progress provider??
    t
    • 2
    • 7
  • p

    powerful-printer-57241

    04/03/2021, 2:48 PM
    I am probably missing something crucial, because Pulumi just deleted a resource after I confirmed a preview with no change indicated. How is it possible?
    • 1
    • 2
  • p

    powerful-printer-57241

    04/03/2021, 4:10 PM
    Is it possible to create stack outputs dynamically? We would like the infrastructure to be entirely declarative, so the necessity of having to imperatively assign to output properties within the stack is problematic. Basically we would need something like this:
    public sealed class AzureAlertStack : Stack
    {
        public AzureAlertStack()
        {
            var alertId = CreateAlert(...);
            RegisterOutput("AlertId", alertId);
        }
    }
    instead of
    public sealed class AzureAlertStack : Stack
    {
        [Output] public Output<string> AlertId { get; set; }
    
        public AzureAlertStack()
        {
            AlertId = CreateAlert(...);
        }
    }
    p
    b
    +2
    • 5
    • 22
  • p

    purple-train-14007

    04/12/2021, 10:13 PM
    Maybe someone can help me out here. I’m kinda stuck on trying to figure out how to do what I want to do. So I want to make a network class with subnets and then new an instance of that class with details from the pulumi config file. I want to do this so the logic is reusable and we don’t have write the same code twice. I thought I could potentially get away with this by using some access modifiers however that won’t work. Any hints in the right direction would help 😇
    t
    • 2
    • 6
  • p

    purple-train-14007

    04/12/2021, 10:14 PM
    To be clear I’m creating two VNets in two regions per stack and the network architecture is identical.
  • b

    breezy-salesmen-85534

    04/13/2021, 11:31 AM
    Here comes my short rant. I have wasted one day on trying to assign access to write logs from Azure application gateway to Azure eventhub. I was working with EventHub.NamespaceAuthorizationRule . I got these really mysterious errors. the system was telling me my eventhub did not exist. I found the issue. i was trying to assign NamespaceName, but the documentation for this property says S_pecifies the name of the ServiceBus Namespace. Changing this forces a new resource to be created._ My solution was to switch class to EventHub.EventHubNamespaceAuthorizationRule . now everything works. This leads me to believe that EventHub.NamespaceAuthorizationRule does not have the right to exist. EventHubNamespaceAuthorizationRule solves my azure Eventhub access rights, and ServiceBus.NamespaceAuthorizationRule solves all mye azure servicebus access rights. Please make EventHub.NamespaceAuthorizationRule go away in a future version of pulumi. 😬.
    t
    • 2
    • 3
  • w

    worried-city-86458

    04/15/2021, 7:33 PM
    I'm returning to this space after a break and then working on other things this year. I'd like to reboot everything to use c#/dotnet via the automation api. Quick questions: • Should I use 2.x or 3.0 beta (or even alpha)? • Is there a timeline for 3.0? (I need to be production ready in a couple of months) • I presume / hope it's much easier to debug stuff via the dotnet automation api? • Will I be able to exploit dotnet config sources to control config composition / overrides and pass it through to the automation api? • Has there been any progress on using dotnet to write dynamic providers? Really looking forward to it! 😀
    t
    b
    b
    • 4
    • 8
  • l

    late-diamond-14259

    04/21/2021, 8:11 PM
    Is it possible to control C# build options when running
    pulumi up
    ? For example I want to run:
    dotnet build /p:GenerateTsProxy=False
    . I want to include the
    /p:GenerateTsProxy=False
    . something like this
    pulumi up -- /p:GenerateTsProxy=False
    b
    • 2
    • 3
  • w

    worried-city-86458

    04/28/2021, 5:59 AM
    More automation api questions... • Are the following cli options still relevant, and if so can they be set? • ...
    --disable-integrity-checking
    --logflow
    --logtostderr
    --verbosity
    • Are there plans to eventually avoid the need for
    InstallPluginAsync
    ? • ... otherwise has anyone tried to automate this step somehow?
    b
    r
    l
    • 4
    • 34
  • w

    worried-city-86458

    04/28/2021, 6:34 AM
    First attempt to use the automation api and I get the following exception:
    System.MissingMethodException: Method not found: 'Void YamlDotNet.Core.Events.MappingStart..ctor(System.String, System.String, Boolean, YamlDotNet.Core.Events.MappingStyle)'.
      at Pulumi.Automation.Serialization.Yaml.ProjectRuntimeYamlConverter.WriteYaml(IEmitter emitter, Object value, Type type)
      at YamlDotNet.Serialization.ObjectGraphVisitors.CustomSerializationObjectGraphVisitor.Enter(IObjectDescriptor value, IEmitter context)
      at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.Traverse[[TContext]](Object name, IObjectDescriptor value, IObjectGraphVisitor`1 visitor, TContext context, Stack`1 path)
      at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.TraverseProperties[[TContext]](IObjectDescriptor value, IObjectGraphVisitor`1 visitor, TContext context, Stack`1 path)
      at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.TraverseObject[[TContext]](IObjectDescriptor value, IObjectGraphVisitor`1 visitor, TContext context, Stack`1 path)
      at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.Traverse[[TContext]](Object name, IObjectDescriptor value, IObjectGraphVisitor`1 visitor, TContext context, Stack`1 path)
      at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.YamlDotNet.Serialization.IObjectGraphTraversalStrategy.Traverse[[TContext]](IObjectDescriptor graph, IObjectGraphVisitor`1 visitor, TContext context)
      at YamlDotNet.Serialization.SerializerBuilder.ValueSerializer.SerializeValue(IEmitter emitter, Object value, Type type)
      at YamlDotNet.Serialization.Serializer.EmitDocument(IEmitter emitter, Object graph, Type type)
      at YamlDotNet.Serialization.Serializer.Serialize(IEmitter emitter, Object graph)
      at YamlDotNet.Serialization.Serializer.Serialize(TextWriter writer, Object graph)
      at YamlDotNet.Serialization.Serializer.Serialize(Object graph)
      at Pulumi.Automation.Serialization.LocalSerializer.SerializeYaml[[T]](T object) in LocalSerializer.cs:41
      at Pulumi.Automation.LocalWorkspace.SaveProjectSettingsAsync(ProjectSettings settings, CancellationToken cancellationToken) in LocalWorkspace.cs:419
      at Pulumi.Automation.LocalWorkspace.InitializeProjectSettingsAsync(ProjectSettings projectSettings, CancellationToken cancellationToken) in LocalWorkspace.cs:355
      at Pulumi.Automation.LocalWorkspace.CreateStackHelperAsync(InlineProgramArgs args, Func`4 initFunc, CancellationToken cancellationToken) in LocalWorkspace.cs:275
      at Pharos.Gemini.DeployCommand.ExecuteAsync(CommandContext context, Settings settings)
    p
    t
    b
    • 4
    • 25
  • c

    creamy-knife-93354

    05/03/2021, 3:13 PM
    Newbie question coming up 🙂 In my stack definition, I'm generating some passwords using Pulumi.Random, which I'm then storing in AWS Secrets Manager. Back in my app, I now want to retrieve said secrets from Secrets Manager, e.g. using
    Kralizek.Extensions.Configuration.AWSSecretsManager
    . However, because Pulumi appends a generated ID to the secret names, I'm not sure what the best way is to map the secrets to .NET POCOs, since my app won't know the exact secret name.. Has anyone got some pro tips on this matter?
    b
    • 2
    • 2
  • w

    worried-city-86458

    05/04/2021, 6:26 AM
    Thoughts and questions re dotnet automation api and configuration... • given I have my own generic host with config, logging, and services (di) etc • automation api for config can effectively be bypassed with config injected directly into stack instance • ... is this safe or will there be some gotchas that I might be missing? • ... I guess still needs to be called if only to record config values used at the time that will then show in the ui? • provider use of config is currently problematic (https://github.com/pulumi/pulumi/issues/5582) • ... could this be lazy initialized or invert control by calling back to the automation host for config? • ... but is this not a problem if you always explicitly instantiate a provider and pass args?
    b
    • 2
    • 11
  • p

    polite-guitar-77512

    05/07/2021, 12:18 PM
    Newbie here. I’m trying to read the azure-native:location config from the Pulumi.{stack}.yaml file. Is this possible?
  • p

    prehistoric-coat-10166

    05/07/2021, 12:20 PM
    new Pulumi.Config("azure-native").Get("location")
    should work
    ➕ 1
  • p

    prehistoric-coat-10166

    05/07/2021, 12:25 PM
    There is also
    Pulumi.AzureNative.Config
    class with some of the configuration options as static members
  • e

    enough-butcher-66045

    05/08/2021, 1:25 PM
    hey guys, I have an AppInsights component being created and I want the ingestion mode to be Loganalytics -- however I can't specify to which LogAnalytics workspace it should go. Even when I import a resource that has the desired configuration in Azure, the resulting C# code doesn't offer a WorkspaceResourceId
    "properties": {
            ...
            "Name": "asasfasfasf",
            "TenantId": "6e9924f5-0f9c-4946-a7e9-a01e08f2a84c",
            "provisioningState": "Succeeded",
            "WorkspaceResourceId": "/subscriptions/blabla/providers/microsoft.operationalinsights/workspaces/test-main",
            "IngestionMode": "LogAnalytics",
        }
    using Pulumi;
    using AzureNative = Pulumi.AzureNative;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            var ai = new AzureNative.Insights.Component("ai", new AzureNative.Insights.ComponentArgs
            {
                ApplicationType = "web",
                FlowType = "Redfield",
                IngestionMode = "LogAnalytics",
                Kind = "web",
                Location = "westus2",
                RequestSource = "IbizaAIExtension",
                ResourceGroupName = "DefaultResourceGroup-EUS",
                ResourceName = "asasfasfasf",
                RetentionInDays = 90,
            }, new CustomResourceOptions
            {
                Protect = true,
            });
        }
    How do I go about describing this scenario? Thanks.
  • e

    enough-butcher-66045

    05/08/2021, 1:51 PM
    I saw in #azure that it's related to https://github.com/pulumi/pulumi-azure-native/issues/737 . Thanks!
  • b

    bored-activity-40468

    05/09/2021, 5:29 PM
    Is the Stack type still used if an InlineProgram is created? Looking at the code it doesn't seem to be. Does the InlineProgram become the roots stack?
    b
    • 2
    • 6
  • b

    boundless-tailor-35598

    05/10/2021, 2:06 PM
    At present I am using a monolithic setup with 1 stack for an entire environment. For a number of reasons it would be handy to separate and have a base environment created in 1 stack and we able to then deploy other stacks using the resources of the base stack. As a concrete example, assume a base stack creates and EC2 public and private subnet, a bastion server, nat instance and a few other pieces. Then I would like to create a new stack to put an application server in the public subnet. What is the best way to reference the resources of the existing stack?
    b
    • 2
    • 2
  • w

    worried-city-86458

    05/11/2021, 8:55 PM
    @bored-oyster-3147 starting a slack thread following on from https://github.com/pulumi/pulumi/pull/7023#issuecomment-839082652 ...
    b
    • 2
    • 11
  • m

    miniature-leather-70472

    05/18/2021, 8:06 AM
    I'm working on converting some modules to the AzureNative provider, but hitting an issue with union lists. If i have a resource that accepts an
    InputList<Union<string, CertificatePermissions>>
    Should I not then be able to pass it an
    InputList<CertificatePermissions>
    This generates a conversion error if I try
    t
    • 2
    • 1
  • m

    miniature-leather-70472

    05/18/2021, 8:53 AM
    Another migration question, updating to Pulumi 3.0 has broken our unit testing mock, the example here seems to have been updated to fix the breaking change, but it doesn't work https://www.pulumi.com/docs/guides/testing/unit/#add-mocks it complains about args not existing, are there any working examples to update the RunAsync method? It also looks like the full code example here https://github.com/pulumi/examples/tree/74db62a03d013c2854d2cf933c074ea0a3bbf69d/testing-unit-cs has not been updated
    t
    • 2
    • 7
  • b

    bumpy-grass-54508

    05/18/2021, 1:24 PM
    Can Assets and Archives safely be created in an Output.Apply? I know resources are not meant to be created there but AssetOrArchive does not look to be related. I have not gathered enough info to have a fully reproducible problem (will create a github issue once I do), but I ask because I am having issues dynamically creating an AWS Lambda function based on a StringAsset:
    Output<string> handlerCode = ... // based on other outputs in the stack
    var handlerArchive = handlerCode.Apply(code => (Archive)new AssetArchive(new Dictionary<string, AssetOrArchive>
    {
        ["index.js"] = new StringAsset(code),
    }));
    
    var function = new Pulumi.Aws.Lambda.Function("function", new Pulumi.Aws.Lambda.FunctionArgs
    {
        Code = handlerArchive,
        Handler = "index.handler",
        Role = role.Arn,
        Runtime = Pulumi.Aws.Lambda.Runtime.NodeJS14dX,
    });
    creating the function works fine, and subsequent
    up
    operations sometimes work fine - but in one particular stack I am working on I consistently get this error
    System.InvalidOperationException: Expected Pulumi.Archive but got System.String deserializing Pulumi.Aws.Lambda.Function.code
       at Pulumi.Serialization.Converter.ConvertObject(String context, Object val, Type targetType)
       at Pulumi.Serialization.Converter.ConvertValue(String context, Value value, Type targetType, ImmutableHashSet`1 resources)
       at Pulumi.Deployment.CompleteResourceAsync(Resource resource, Boolean remote, Func`2 newDependency, ResourceArgs args, ResourceOptions options, ImmutableDictionary`2 completionSources)
       at Pulumi.Deployment.Runner.<>c__DisplayClass9_0.<<WhileRunningAsync>g__HandleCompletion|0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Pulumi.Deployment.Runner.WhileRunningAsync()<{%reset%}>)
    want to double check I should even be creating this Archive in an Apply or if that is not supported
    t
    • 2
    • 11
  • w

    worried-city-86458

    05/19/2021, 9:01 PM
    The dotnet automation is logging with serilog, which is great, but without setting
    SourceContext
    , which is used to configure logging per source.
    t
    b
    • 3
    • 16
Powered by Linen
Title
w

worried-city-86458

05/19/2021, 9:01 PM
The dotnet automation is logging with serilog, which is great, but without setting
SourceContext
, which is used to configure logging per source.
I'm using
config.Development.yml
to configure logging:
Serilog:
  MinimumLevel:
    Override:
      Microsoft: Information
      Microsoft.Hosting.Lifetime: Warning
  WriteTo:
    - Name: Seq
      Args:
        serverUrl: <http://localhost:5341>
But I can't control the dotnet automation api logging without a source context
This should be a matter of using
ILogger<T>
instead of
ILogger
where type
T
becomes the source context
public sealed partial class DeployCommand : AsyncCommandBase<DeployCommand.Settings>
{
    public DeployCommand(IOptions<Config> options, ILogger<DeployCommand> logger, IServiceProvider serviceProvider) : base(options, logger)
    {
    }

    protected override async Task<int> OnExecuteAsync(CommandContext context, Settings settings)
    {
        Logger.LogInformation("Deploying resources...");
        using var totalTimeLogger = new ElapsedTimeLogger(Logger, "Deployed resources");
        ...
    }
}

public abstract class AsyncCommandBase<TSettings> : AsyncCommand<TSettings> where TSettings : CommandSettings
{
    protected AsyncCommandBase(IOptions<Config> options, ILogger logger)
    {
        Config = options.Value;
        Logger = logger;
    }

    protected Config Config { get; }
    protected ILogger Logger { get; }
}
@bored-oyster-3147 @tall-librarian-49374 ^
t

tall-librarian-49374

05/20/2021, 5:46 AM
This makes sense to me. Open an issue? (PR?)
👍 1
w

worried-city-86458

05/20/2021, 7:53 AM
https://github.com/pulumi/pulumi/issues/7093 (looking at PR too)
🎉 1
b

bored-oyster-3147

05/20/2021, 10:46 AM
AFAIK this is not an automation API thing. The core lib uses serilog so that is what you are seeing. Also it doesn’t use Microsoft.Extensions.Logging.ILogger. It uses a home rolled ILogger where the implementation is in Pulumi.Deployment.Logger which calls out to some static serilog methods.
w

worried-city-86458

05/20/2021, 10:59 AM
Yeah I was just looking through the code and that's exactly right. Using the global shared serilog logger is messy but I can hack it to use a static
Serilog.Log.ForContext<Deployment>()
. It gets ugly when
PULUMI_DOTNET_LOG_VERBOSE
is defined as this creates a new logger which wipes my sinks.
I'll send a PR for further discussion...
https://github.com/pulumi/pulumi/pull/7095
Normally configuration of logging levels would be done via host configuration. I wire up everything in my generic host, so if pulumi interacted with that it wouldn't need to recreate the logger.
Meanwhile the quick fix in my PR will inject a source context of
Pulumi.Deployment
so I can control it with say:
Serilog:
  MinimumLevel:
    Override:
      Pulumi.Deployment: Debug
(In this case I'll actually silence it by default because it makes my logs unreadable)
Gemini.log
See the logging from a deploy is 99% noise from
Pulumi.Deployment
View count: 1