https://pulumi.com logo
#azure
Title
# azure
c

careful-state-15277

02/20/2020, 2:05 PM
Dumb question, but is there a way of getting a string out of an Outpus<string> using the C# SDK?
m

microscopic-pilot-97530

02/20/2020, 3:13 PM
Use
Apply
. See https://www.pulumi.com/docs/intro/concepts/programming-model/#apply
Copy code
var url = virtualmachine.DnsName.Apply(dnsName => "https://" + dnsName);
c

careful-state-15277

02/20/2020, 3:18 PM
Thank you for the response Justin, but doesn't the Apply method still returns an Output of something?
My use case is to generate a SAS token via
Pulumi.Azure.Storage.Invokes.GetAccountBlobContainerSAS
for a storage account I'm creating but the GetAccountBlobContainerSASArgs has strings properties instead of Inputstring parameters
m

microscopic-pilot-97530

02/20/2020, 3:31 PM
You'll need to call
GetAccountBlobContainerSAS
inside the
Apply
where the argument will be a string.
c

careful-state-15277

02/20/2020, 3:35 PM
Works like a charm, thanks!
🎉 1
t

tall-librarian-49374

02/20/2020, 4:24 PM
Great that you made it work. Note that we have
SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);
in the standard library.
c

careful-state-15277

02/20/2020, 4:25 PM
Nice, will look into that one. BTW I love pulumi guys
c

careful-state-15277

02/20/2020, 4:27 PM
turned >3k LOC of ARM template into ~500 lines of C#
t

tall-librarian-49374

02/20/2020, 4:29 PM
Nice! Maybe you can pack it up even further 🙂
c

careful-state-15277

02/20/2020, 4:30 PM
Sure, but I'm just starting out
so I still have a lot to learn here
I have one question, can I somehow import an existing resource group into a pulumi stack?
t

tall-librarian-49374

02/20/2020, 4:31 PM
yes you can. do you want to just reference it to retrieve its property or do you want to start managing it from pulumi?
c

careful-state-15277

02/20/2020, 4:32 PM
My plan is to throw away the arm template and replace it with pulumi, the problem is that pulumi generates names that differ from the one I've generated already
thanks, will look into it!
t

tall-librarian-49374

02/20/2020, 4:33 PM
you can override the default names
c

careful-state-15277

02/20/2020, 4:33 PM
you mean by specifinng the whole name?
t

tall-librarian-49374

02/20/2020, 4:33 PM
yes
c

careful-state-15277

02/20/2020, 4:33 PM
I know but for ~100 resources is a bit tedious to do
that's eventually my plan
I was hoping to find something smarter though 🙂
t

tall-librarian-49374

02/20/2020, 4:35 PM
like what?
c

careful-state-15277

02/20/2020, 4:36 PM
like importing the existing resources into a stack so pulumi can use the existing names instead of generating new ones but I have to admit I didn't read the docs on that part because I'm just focusing on creating the equivalent of the arm template now
so I may have missed something there
t

tall-librarian-49374

02/20/2020, 4:40 PM
So “adopting” above is the way to import resources, but you still have to write code for them manually and resolve IDs (not names). There’s no auto-import tool currently.
3 Views