This message was deleted.
# azure
s
This message was deleted.
t
You likely need to put the
native:cache:listRedisKeys
call inside an apply, similar to https://github.com/pulumi/templates/blob/master/azure-typescript/index.ts#L18-L19
That way it will only run after the redis server is created
a
but it is in an apply call, look at the code - or am I missing something?
t
Oh, sorry, I didn’t read the code correctly… let me try it locally.
a
thx!
t
Hmm… this preview works for me
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as resources from "@pulumi/azure-native/resources";
import * as redis from "@pulumi/azure-native/cache";

const resourceGroup = new resources.ResourceGroup("rg");

var cache= new redis.Redis("redis", {
    resourceGroupName: resourceGroup.name,
    enableNonSslPort: true,
    minimumTlsVersion: redis.TlsVersion.TlsVersion_1_2,
    sku: {
        name: "Basic",
        family: "C",
        capacity: 1
    }
});
const keys= pulumi.all([resourceGroup.name, cache.name])
             .apply(([resourceGroupName, name])=>redis.listRedisKeys({resourceGroupName, name}))
export const connectionString= pulumi.interpolate `${cache.hostName}:6380,password=${keys.primaryKey},ssl=True,abortConnect=False`;
a
could it be because I do the `const connectionstring =...`outside the apply? if yes, then how exactly would I rewrite that?
t
No, interpolate does the right thing
a
hmm. how can I dig further?
t
Can you run my code in isolation and see you get the same?
a
could it matter that the resourcegroup is not being created by pulumi? because that I changed, I now supply it's name via config. (Background: i need to create and configure a b2c instance outside of pulumi because what I need to there doesn't work within.)
run in a new stack?
t
Aha! Yes, I reproduced your error with an existing RG.
a
ah
okay, then I try what happens if I get the resourcegroup by name and use then resourcegroup.Name
maybe that is a workaround
t
The workaround is to change
all
to this:
Copy code
const keys= pulumi.all([resourceGroup.name, cache.name, cache.id])
cache.id
won’t resolve until redis exists. But it may be worth filing an issue for your original code.
a
ah, thx for the workaround
re issue - github?
t
a
ok
t
please mention the pre-existing resource group
a
hmm. I have a related question: In order to get the existing resourcegroup, I first tried to do just
Copy code
const resourceGroup= new resources.ResourceGroup(resourceGroupName);
for preview that looked fine, but when I run it, it leads to the creation of a new resourcegroup. on the other hand, when I do
Copy code
const resourceGroup= resources.getResourceGroup({resourceGroupName});
then the result is a `Promise<GetResourceGroupResult>`and I get compile-time errors. when I try
Copy code
const resourceGroup= await resources.getResourceGroup({resourceGroupName});
I get another error saying that top-level await is not allowed. So what do I do?
ah, I see I misunderstood your workaround
t
yes, you don’t have to do that