Ciao! Dynamic Providers are still not supported in...
# dotnet
l
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
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
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
@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
@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
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
FWIW, it looks like we’ll have native support for Azure static websites really soon
🎉 1
💯 1
s
f
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
I actually fixed this in my local version. Let me see if I can push this to PR…
f
Awesome @tall-librarian-49374, that was extremely fast response 👍.
t
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
I just tested without uploading the files and still not working for me. I will test with uploading the files now
t
Hmm, then it’s a different problem. What is the error that you get?
f
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
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
Yes, the files were failing for me, so added this sequencing workaround
👍 1