https://pulumi.com logo
#dotnet
Title
# dotnet
l

little-kangaroo-50941

02/24/2020, 9:54 AM
Ciao! Dynamic Providers are still not supported in .NET correct? Is there a way to create the $Web folder in an Azure Storage Account using C# ?
t

tall-librarian-49374

02/24/2020, 12:36 PM
This is correct. Check this post https://blog.headforcloud.com/2020/02/09/pulumi-azure-static-sites/ for a workaround
❤️ 1
I’m going to make an example out of it and push to examples this week.
l

little-kangaroo-50941

02/24/2020, 12:56 PM
Thank you Mikhail!! And do you know if there are some problems on Pulumi service today? Because trying a pulumi up command results in infinite command line wait without any response, I also tried to recreate the stack from scratch... 🤔
s

stocky-crayon-93563

02/24/2020, 5:31 PM
@tall-librarian-49374 I was going to submit that as an example soon - say you a job. Also had a few other examples
❤️ 1
t

tall-librarian-49374

02/24/2020, 5:33 PM
@stocky-crayon-93563 That would be fabulous! I extended your example to upload Blob files from the folder on local disk, so that the website is immediately clickable. If you could do the same, double kudos!
👍 1
@little-kangaroo-50941 That doesn’t sound right. Maybe ask in the main channel?
l

little-kangaroo-50941

02/24/2020, 5:34 PM
Sorry Mikhail I solved, and was my mistake
I tried to debug the Program.cs without success
I saw this https://github.com/pulumi/pulumi/issues/1372 but it seems it doesn’t work
t

tall-librarian-49374

02/24/2020, 7:03 PM
FWIW, it looks like we’ll have native support for Azure static websites really soon
🎉 1
💯 1
s

stocky-crayon-93563

02/24/2020, 7:28 PM
f

flat-mouse-20634

02/26/2020, 8:35 AM
Hey, Good one @stocky-crayon-93563, I know this might sound crazy but I couldn’t get enabling static site to work unless I switch the
EnableStaticSites
to synchronous call so my call to EnableStaticSites is like this
Copy code
if (!Deployment.Instance.IsDryRun)
                storageAccount.PrimaryBlobConnectionString.Apply(v => EnableStaticSites(v) );
and the method looks like this
Copy code
static string EnableStaticSites(string connectionString)
        {
            CloudStorageAccount sa = CloudStorageAccount.Parse(connectionString);

            var blobClient = sa.CreateCloudBlobClient();
            ServiceProperties blobServiceProperties = new ServiceProperties();
            blobServiceProperties.StaticWebsite = new StaticWebsiteProperties
            {
                Enabled = true,
                IndexDocument = "index.html",
                ErrorDocument404Path = "404.html"
            };
            blobClient.SetServicePropertiesAsync(blobServiceProperties).Wait();
            return connectionString;
        }
Do you have any suggestions? @tall-librarian-49374
t

tall-librarian-49374

02/26/2020, 8:36 AM
I actually fixed this in my local version. Let me see if I can push this to PR…
f

flat-mouse-20634

02/26/2020, 8:40 AM
Awesome @tall-librarian-49374, that was extremely fast response 👍.
t

tall-librarian-49374

02/26/2020, 8:58 AM
I merged the example to https://github.com/pulumi/examples/tree/master/azure-cs-static-website and added a workaround to make files depend on the static $web container
👍 1
Let me know if that works for you
f

flat-mouse-20634

02/26/2020, 9:14 AM
I just tested without uploading the files and still not working for me. I will test with uploading the files now
t

tall-librarian-49374

02/26/2020, 9:22 AM
Hmm, then it’s a different problem. What is the error that you get?
f

flat-mouse-20634

02/26/2020, 9:34 AM
I didn’t get any errors actually, the resource group and storage account created but it was never marked as static site. I tested with blob upload and the site was marked as static. That made me think that may be because it is an Output and nothing depends on it, the application was closing before it is resolved which might mean closing before finishing the EnableStaticSite (I am just guessing). I have removed the upload of blob files and put the containerName into the return dictionary and it worked like magic
Copy code
{"containerName", containerName}
I think my guess is kind of right, I have removed the
containerName
from the returned dictionary and put Console.Writeline around
SetServicePropertiesAsync
Copy code
Console.WriteLine("Before SetServicePropertiesAsync");
		        await blobClient.SetServicePropertiesAsync(blobServiceProperties);
                Console.WriteLine("After SetServicePropertiesAsync");
After I run, I can see only
Before SetServicePropertiesAsync
in the diagnostics messages
s

stocky-crayon-93563

02/26/2020, 1:44 PM
Thanks for updating that example @tall-librarian-49374 I had wondered if my initial example would potentially have a race condition where the files are uploaded before the $web folder is created.
t

tall-librarian-49374

02/26/2020, 3:04 PM
Yes, the files were failing for me, so added this sequencing workaround
👍 1
2 Views