I´m having problems getting redis to work with up....
# getting-started
s
I´m having problems getting redis to work with up... If I run the following code once it is created but the next time I run up I get the following error. [edit] maybe
var redis = new AzureNative.Cache.Redis("redisCacheBeinni",
should be
var redis = new AzureNative.Cache.Redis("redis",
.. going to try that... [edit2] ok that solved it.. also it took for ever to create this resource and I think I gave up last time before it finished and everything went south from there...
Copy code
var redis = new AzureNative.Cache.Redis("redisCacheBeinni", new AzureNative.Cache.RedisArgs
        {
            EnableNonSslPort = true,
            Location = ResourceGroup.Apply(t => t.Location),
            MinimumTlsVersion = "1.2",
            Name = "redisCacheBeinni",
            RedisConfiguration = new AzureNative.Cache.Inputs.RedisCommonPropertiesRedisConfigurationArgs
            {
                MaxmemoryPolicy = "allkeys-lru",
            },
            ResourceGroupName = ResourceGroup.Apply(t => t.Name),
            Sku = new AzureNative.Cache.Inputs.SkuArgs
            {
                Capacity = 1,
                Family = "C",
                Name = "Standard",
            },
            Tags =
            {
                { "environment", StackName },
            },
        });
this is the error...
error: cannot create already existing resource '/subscriptions/0e96.../resourceGroups/beinni-rg52d042de/providers/Microsoft.Cache/redis/redisCacheBeinni'
Shouldn´t this be re-runnable? If I need to run this once and then import this resource (don´t know how) that sounds like a bug.. or at least not what I would expect I also see that all other resources are created with a postfix but redis is just created as
redisCacheBeinni
in the portal.. And btw its never created in the Pulumi portal either...
b
@sticky-exabyte-94099 you are giving things explicit names all the time. You need to take advantage of Pulumi's autonaming
s
Sorry for that @billowy-army-68599 but I´m just using the examples. You had pointed that out previously and I only found this https://www.pulumi.com/docs/intro/concepts/resources/ and it really does not tell me a whole lot how to use it.. can you point me to one example using it?
b
every resource has a property where you can explicitly set the name, you're doing it in your redis cache:
Copy code
Name = "redisCacheBeinni",
If you explicitly set the names like this, you'll end up with resource collisions. Just remove this property:
Copy code
var redis = new AzureNative.Cache.Redis("redisCacheBeinni", new AzureNative.Cache.RedisArgs
        {
            EnableNonSslPort = true,
            Location = ResourceGroup.Apply(t => t.Location),
            MinimumTlsVersion = "1.2",
            RedisConfiguration = new AzureNative.Cache.Inputs.RedisCommonPropertiesRedisConfigurationArgs
            {
                MaxmemoryPolicy = "allkeys-lru",
            },
            ResourceGroupName = ResourceGroup.Apply(t => t.Name),
            Sku = new AzureNative.Cache.Inputs.SkuArgs
            {
                Capacity = 1,
                Family = "C",
                Name = "Standard",
            },
            Tags =
            {
                { "environment", StackName },
            },
        });
And a lot of the problems you're having will go away
by removing this property, Pulumi will append a random string to resources so there isnt a collision when something exists
if you want to use explicit names, you'll need to A) make sure the resource doesn't exist in Azure yet and B) set the
deleteBeforeReplace
property on your resources so the old one is removed before the new one. This is explained here: https://www.pulumi.com/docs/troubleshooting/faq/#why-do-resource-names-have-random-hex-character-suffixes
s
ahhhhhhhh... OK so skip the property!! I really think you should have Pulumi for Dummies... really short and to the point...you have way to much text to cover... I guess I´m writing the first chapters in that book 🤣 like I have said before, please don´t give up on me!
b
we won't!
👍 1
s
Ok kinda lost now...I added your code and now every time I do up another redis is created
There is just one difference and that is this
Copy code
Redis = Output.Create(new AzureNative.Cache.Redis("redisCacheBeinni", new AzureNative.Cache.RedisArgs
{
});
I´m using the Redis output in another method. Maybe I should´t be doing that but should a new Redis be created every time just because of that?
ok the updates failed each time but had created the resource.. I thought that Pulumi would "know" about that and re-use what was up..
b
you're creating a new resource inside an output?
s
Maybe I´m totally using this wrong. I was organizing my project into methods and I have been using Output for all the properties that I´m moving around to use in other methods. Like here https://github.com/sturlath/MyTest/blob/824d1618346bb50bccd93d6f7a7b68580352a774/AppStack.cs#L69 Maybe this should just be
AppServicePlan = new Plan
and instead of
[Output] public Output<Plan> AppServicePlan { get; set; }
it should just be regular C#
public Plan AppServicePlan { get; set; }
b
yeah that'll create a new resource because it's async
I'm not super familiar with C# so can't talk to how it should be laid out
but this explains a lot of the issues you've been having
👍 1