https://pulumi.com logo
Title
i

icy-football-94152

06/29/2021, 8:19 AM
I have noticed that my program based on the Pulumi automation api will return to signal a complete deployment before some resources are fully initialized on Azure. A managed SQL database or Cosmosdb typically take a few extra minutes to fully create and a managed instance of Redis requires 5 to 10 minutes. What additional events can I monitor to identify when slow-to-create resources are fully initialized and ready for use? I suppose I am looking for the programmatic equivalent the notification in-box on the Azure Portal.
b

brave-planet-10645

06/29/2021, 9:19 AM
The issue here is that the Azure API tells Pulumi that it's done before the deployment has taken place. You could set up polling to check when the resource has finished deploying?
g

gorgeous-country-43026

06/29/2021, 10:13 AM
Same thing happens with public IP address allocation. API says it's done even if the address is not available yet
This is an example of me handling this scenario with Kubernetes Ingress Controller:
const ingressIpDone = pulumi.all({
    name: ingress.ingressLoadbalancerIP.name,
    resourceGroupName: cluster.nodeResourceGroupName
});

const ingressIP = ingressIpDone.apply(d => {
    return azure.network.getPublicIP({
        name: d.name,
        resourceGroupName: d.resourceGroupName
    }, { async: true }).then(ip => ip.ipAddress);
});
💯 1
Now I can just refer to
ingressIP
and it's an
Output
that gets realized after the IP address is available
So basically what it does is that it first waits for the Azure API to say that "yeah, IP created". This is the first part of the code. Then when this happens it explicitly queries Azure API for details regarding that resource
Azure does create the resource immediately after the API call has been made, it just doesn't mean it's ready for usage
i

icy-football-94152

06/29/2021, 11:24 AM
@brave-planet-10645 sure I appreciate that Pulumi just reflects responses from api calls to Azure. Since starting this question I looked at the resource activity log that can be viewed via the Azure Portal for each resource. The activity log events seem to track the real resource creation progress events behind the api calls. There is something called the Azure Resource Graph with an associated KQL query language. Maybe I could join across all resources in a resource-group the Azure resource activity log and the resources created in a stack.UpAsync() call. https://docs.microsoft.com/en-us/azure/governance/resource-graph/overview
@gorgeous-country-43026 as you say, on return from a Pulumi UP call the Azure resources are created and I can see them listed in the Azure Portal within seconds. "Ready for use" is a subsequent progress event in what I assume is a mini internal state-machine within Azure for each resource creation event.
g

gorgeous-country-43026

06/29/2021, 11:33 AM
Yeah. You just need to figure out how to find out when that specific resource is actually ready. It can be practically anything
If you want to connect a managed database (like postgre) you can try to use normal SQL libraries
If it is unreachable from where you are running Pulumi then you need to do something else
i

icy-football-94152

06/29/2021, 11:35 AM
@gorgeous-country-43026 I cannot find pulumi.All() in the .Net automation API, I assume you are using TypeScript or Go?
g

gorgeous-country-43026

06/29/2021, 11:37 AM
TypeScript yes
@icy-football-94152 it is
Output.All
apparently
in .NET