1. How to upload code to Azure web apps?

    TypeScript

    Sure, here is a step by step Pulumi program that accomplishes this goal in TypeScript:

    To upload code to Azure Web Apps, we first need to create the Web App where your application will be hosted. Azure-native is the preferred package provider we use for Azure. Here we will create a ResourceGroup, an AppServicePlan (the hosting plan for the web app), and the WebApp itself.

    After creating those, Pulumi provides Archive and Asset classes to upload our local files to the cloud. You'll find these classes in the @pulumi/pulumi package under the automation module.

    The AssetArchive and FileAsset classes can point to local files for Pulumi to upload. When we apply these as the content in the Input for appService.WebApp Pulumi uploads those files to Azure.

    Here is the Pulumi program:

    import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure-native"; // Name for our resources const name = "pulumiai"; // Create an azure resource group const resourceGroup = new azure.resources.ResourceGroup(`${name}-rg`); // Create an AppServicePlan const appServicePlan = new azure.web.AppServicePlan(`${name}-asp`, { resourceGroupName: resourceGroup.name, kind: "App", sku: { name: "Y1", tier: "Free", }, }); // Create a WebApp const webapp = new azure.web.WebApp(`${name}-webapp`, { resourceGroupName: resourceGroup.name, serverFarmId: appServicePlan.id, siteConfig: { appSettings: [ { name: "WEBSITE_RUN_FROM_PACKAGE", value: "1" }, ] }, }); // Locate the web app's deploy slot const deploySlot = webapp.getCurrentDeploymentSlot("azure:api-version=2020-12-01"); // Prepare the WebApp upload const archive = new pulumi.asset.FileArchive("./wwwroot"); // example file archive // Upload to the newly created deploy slot deploySlot.uploadWebAppArchive("2020-12-01", archive) .then(_ => console.log("deployment succeeded")) .catch(err => console.error("deployment failed", err));

    In the example above, replace ./wwwroot with the path to your project's website root. The ./ is relative to the Pulumi program, so depending on your setup, it might be "../wwwroot" or "./public".

    This program will take the files in your project's "wwwroot" directory (or whichever directory you specify), create an Azure Web App in a new Resource Group, and then upload those files to the newly created Azure Web App.

    Finally, the URL for your website will be {webapp.name}.azurewebsites.net.

    Let me know if there's anything else you'd like me to help you with when it comes to deploying on Azure with Pulumi!