Created
February 24, 2021 12:03
-
-
Save pierskarsenbarg/20d9f8d1e2d89efc0ef5187c06b9f06a to your computer and use it in GitHub Desktop.
Revisions
-
pierskarsenbarg created this gist
Feb 24, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using Pulumi; using Pulumi.AzureNextGen.Resources.Latest; using Pulumi.AzureNextGen.Storage.Latest; using Pulumi.AzureNextGen.Storage.Latest.Inputs; using Pulumi.Random; class MyStack : Stack { public MyStack() { // Create an Azure Resource Group var resourceGroup = new ResourceGroup("resourceGroup", new ResourceGroupArgs { ResourceGroupName = "my-rg", Location = "WestUS" }); var waitComplete = resourceGroup.Name.Apply(x => Wait(x)); var randomWaiter = new RandomString("randomString", new RandomStringArgs { Length = 5, Keepers = new Dictionary<string, object> { { "upstream", waitComplete } } }); // Create an Azure resource (Storage Account) var storageAccount = new StorageAccount("sa", new StorageAccountArgs { ResourceGroupName = resourceGroup.Name, AccountName = "piersstorage123", Location = resourceGroup.Location, Sku = new SkuArgs { Name = SkuName.Standard_LRS }, Kind = Kind.StorageV2 }, new CustomResourceOptions { DependsOn = randomWaiter }); } private async Task<string> Wait(string name) { if (!Pulumi.Deployment.Instance.IsDryRun) { const int WaitTime = 10; Console.WriteLine($"Waiting for {WaitTime} seconds"); await Task.Delay(WaitTime * 1000); } return name; } }