Skip to content

Instantly share code, notes, and snippets.

@pierskarsenbarg
Created February 24, 2021 12:05
Show Gist options
  • Select an option

  • Save pierskarsenbarg/174d26da3d9f462b33370d320caa38c8 to your computer and use it in GitHub Desktop.

Select an option

Save pierskarsenbarg/174d26da3d9f462b33370d320caa38c8 to your computer and use it in GitHub Desktop.
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 resourceGroupName = resourceGroup.Name.Apply(x => Wait(x));
// Create an Azure resource (Storage Account)
var storageAccount = new StorageAccount("sa", new StorageAccountArgs
{
ResourceGroupName = resourceGroupName,
AccountName = "piersstorage123",
Location = resourceGroup.Location,
Sku = new SkuArgs
{
Name = SkuName.Standard_LRS
},
Kind = Kind.StorageV2
});
}
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment