From c9ccfabd1f9f779ca8e5959db2ef104de71ceb1e Mon Sep 17 00:00:00 2001 From: Thomas Beck Date: Mon, 15 Aug 2022 22:24:17 +0000 Subject: [PATCH] create statiq azure web app for beckshome blog --- MyStack.cs | 28 ++++++++++++++++++++++++++++ blobs/wwwroot/404.html | 5 +++++ blobs/wwwroot/index.html | 5 +++++ 3 files changed, 38 insertions(+) create mode 100644 blobs/wwwroot/404.html create mode 100644 blobs/wwwroot/index.html diff --git a/MyStack.cs b/MyStack.cs index 5faf639..6f78a87 100644 --- a/MyStack.cs +++ b/MyStack.cs @@ -122,9 +122,36 @@ public MyStack() Source = new FileAsset("./blobs/public/rosslyn-classes.txt"), }); + var staticWebsite = new StorageAccountStaticWebsite("staticBeckshomeBlog", new StorageAccountStaticWebsiteArgs + { + AccountName = storageAccount.Name, + ResourceGroupName = resourceGroup.Name, + IndexDocument = "index.html", + Error404Document = "404.html" + }); + + var indexHtmlBlob = new Blob("index.html", new BlobArgs + { + AccountName = storageAccount.Name, + ContainerName = staticWebsite.ContainerName, + ResourceGroupName = resourceGroup.Name, + Source = new FileAsset("./blobs/wwwroot/index.html"), + ContentType = "text/html" + }); + + var notFoundBlob = new Blob("404.html", new BlobArgs + { + AccountName = storageAccount.Name, + ContainerName = staticWebsite.ContainerName, + ResourceGroupName = resourceGroup.Name, + Source = new FileAsset("./blobs/wwwroot/404.html"), + ContentType = "text/html" + }); + this.PrimaryStorageKey = GetStorageAccountPrimaryKey(resourceGroup.Name, storageAccount.Name); this.PrimaryConnectionString = Output.Format($"DefaultEndpointsProtocol=https;AccountName={storageAccount.Name};AccountKey={this.PrimaryStorageKey};EndpointSuffix=core.windows.net"); this.RoslynClassUrl = Output.Format($"https://{storageAccount.Name}.blob.core.windows.net/public/rosslyn-classes.txt"); + this.StaticEndpoint = storageAccount.PrimaryEndpoints.Apply(primaryEndpoints => primaryEndpoints.Web); // Create Cognitive / Storage Service var cogntiveAccount = new Pulumi.AzureNative.CognitiveServices.Account("beckshome-translation-2", new Pulumi.AzureNative.CognitiveServices.AccountArgs @@ -358,6 +385,7 @@ public MyStack() [Output] public Output RosettaStoneEndpoint { get; set; } [Output] public Output RoslynApiEndpoint { get; set; } [Output] public Output RoslynClassUrl { get; set; } + [Output] public Output StaticEndpoint {get; set;} [Output] public Output SheetsNotificationEndpoint { get; set; } [Output] public Output PrimaryStorageKey { get; set; } [Output] public Output PrimaryConnectionString {get; set;} diff --git a/blobs/wwwroot/404.html b/blobs/wwwroot/404.html new file mode 100644 index 0000000..6658760 --- /dev/null +++ b/blobs/wwwroot/404.html @@ -0,0 +1,5 @@ + + +

That's a 404! Still, from the Blob Storage.

+ + \ No newline at end of file diff --git a/blobs/wwwroot/index.html b/blobs/wwwroot/index.html new file mode 100644 index 0000000..af5f75b --- /dev/null +++ b/blobs/wwwroot/index.html @@ -0,0 +1,5 @@ + + +

This file is served from Blob Storage (courtesy of Pulumi!)

+ + \ No newline at end of file