1. Geo-redundant backup storage for Container Storage Account

    TypeScript

    In Azure, enabling geo-redundant storage (GRS) for a storage account provides high availability by replicating your data to a secondary location that is far away from the primary location. This ensures that if the primary location is unavailable due to a disaster, the data in the secondary location can be used.

    For this purpose, we will be using the azure-native.storage.StorageAccount resource from Pulumi's Azure Native provider. This resource allows us to create and configure an Azure Storage Account. When creating a storage account, you can specify the type of replication you want, including GRS, which we will use to create a geo-redundant backup.

    Here's a TypeScript Pulumi program that sets up a storage account with GRS:

    import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; const resourceGroupName = "my-resource-group"; // Use an existing resource group name // Create a Storage Account with Geo-Redundant Storage const storageAccount = new azure_native.storage.StorageAccount("myGeoRedundantStorageAccount", { // Provide the name of your resource group resourceGroupName: resourceGroupName, // Set the location where you'd like to create the storage account location: azure_native.storage.Locations.WestUS, // Choose the kind of account, BlobStorage, BlockBlobStorage, FileStorage, Storage, or StorageV2 (general purpose v2) kind: azure_native.storage.Kind.StorageV2, // Set GRS as the replication strategy for geo-redundancy sku: { name: azure_native.storage.SkuName.Standard_GRS, }, // Additional settings can be specified based on requirements // For example, you can enforce HTTPS-only access as follows enableHttpsTrafficOnly: true, }); // Export the connection string for the storage account const connectionString = storageAccount.primaryEndpoints.apply(endpoints => `DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccount.primaryAccessKey};EndpointSuffix=core.windows.net`); export const storageAccountConnectionString = connectionString; export const storageAccountName = storageAccount.name;

    In this program, we create a GRS-enabled storage account by specifying Standard_GRS in the sku.name property when creating the storage account. The kind property is set to StorageV2, which is the latest version of the storage account and supports all workloads, including blobs, files, queues, and tables. The connection string to the storage account is built using the primary endpoints and keys. This connection string is useful for applications and services that need to access the storage account.

    Make sure to replace "my-resource-group" with the actual name of the resource group where you want to create the storage account. The location can also be updated to a region closer to where you want your primary datacenter.

    Exported values at the end of the program can be viewed through the Pulumi CLI by running pulumi stack output after deployment, giving you the information needed to connect to and utilize the storage account.