Ejemplo n.º 1
0
    public WebsiteStack()
    {
        var resourceGroup = new ResourceGroup("www-prod-rg", new ResourceGroupArgs
        {
            Tags = { { "Environment", "production" } }
        });

        var storageAccount = new Storage.Account("wwwprodsa", new Storage.AccountArgs
        {
            ResourceGroupName      = resourceGroup.Name,
            AccountTier            = "Standard",
            AccountReplicationType = "LRS",
            StaticWebsite          = new Storage.Inputs.AccountStaticWebsiteArgs
            {
                IndexDocument = "index.html"
            }
        });

        var files = Directory.GetFiles("wwwroot");

        foreach (var file in files)
        {
            var blob = new Storage.Blob(file, new Storage.BlobArgs
            {
                ContentType          = "application/html",
                Source               = new FileAsset(file),
                StorageAccountName   = storageAccount.Name,
                StorageContainerName = "$web",
                Type = "Block"
            });
        }

        this.Endpoint = storageAccount.PrimaryWebEndpoint;
    }
Ejemplo n.º 2
0
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("my-group");

        var storageAccount = new Azure.Storage.Account("storage", new Azure.Storage.AccountArgs
        {
            ResourceGroupName      = resourceGroup.Name,
            AccountReplicationType = "LRS",
            AccountTier            = "Standard"
        });

        var plan = new Azure.AppService.Plan("asp", new Azure.AppService.PlanArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Kind = "FunctionApp",
            Sku  = new Azure.AppService.Inputs.PlanSkuArgs
            {
                Tier = "Dynamic",
                Size = "Y1"
            }
        });

        var container = new Azure.Storage.Container("zips", new Azure.Storage.ContainerArgs
        {
            StorageAccountName  = storageAccount.Name,
            ContainerAccessType = "private",
        });

        var blob = new Azure.Storage.Blob("zip", new Azure.Storage.BlobArgs
        {
            StorageAccountName   = storageAccount.Name,
            StorageContainerName = container.Name,
            Type   = "Block",
            Source = new FileArchive("./functions"),
        });

        var codeBlobUrl = Azure.Storage.SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);

        var app = new Azure.AppService.FunctionApp("fa", new Azure.AppService.FunctionAppArgs
        {
            ResourceGroupName       = resourceGroup.Name,
            AppServicePlanId        = plan.Id,
            StorageConnectionString = storageAccount.PrimaryConnectionString,
            Version     = "~2",
            AppSettings =
            {
                { "FUNCTIONS_WORKER_RUNTIME",     "node"      },
                { "WEBSITE_NODE_DEFAULT_VERSION", "10.14.1"   },
                { "WEBSITE_RUN_FROM_PACKAGE",     codeBlobUrl }
            }
        });

        this.Endpoint = Output.Format($"https://{app.DefaultHostname}/api/hello");
    }
Ejemplo n.º 3
0
    public BotStack()
    {
        var config  = new Pulumi.Config();
        var botName = config.Require("botName");

        var resourceGroup = new ResourceGroup("botservice-rg");

        var storageAccount = new Storage.Account("sa", new Storage.AccountArgs
        {
            ResourceGroupName      = resourceGroup.Name,
            AccountReplicationType = "LRS",
            AccountTier            = "Standard"
        });

        var appServicePlan = new Plan("asp", new PlanArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Kind = "App",
            Sku  = new PlanSkuArgs
            {
                Tier = "Basic",
                Size = "B1"
            }
        });

        var container = new Storage.Container("zips", new Storage.ContainerArgs
        {
            StorageAccountName  = storageAccount.Name,
            ContainerAccessType = "private",
        });

        var blob = new Storage.Blob("zip", new Storage.BlobArgs
        {
            StorageAccountName   = storageAccount.Name,
            StorageContainerName = container.Name,
            Type   = "Block",
            Source = new FileArchive("bot/publish")
        });

        var codeBlobUrl = Storage.SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);

        var appInsights = new Insights("ai", new InsightsArgs
        {
            ApplicationType   = "web",
            ResourceGroupName = resourceGroup.Name
        });

        var appInsightApiKey = new ApiKey("ai", new ApiKeyArgs
        {
            ApplicationInsightsId = appInsights.Id,
            ReadPermissions       = "api",
        });

        var luis = new Cognitive.Account("cs", new Cognitive.AccountArgs
        {
            Kind = "CognitiveServices", // includes LUIS
            ResourceGroupName = resourceGroup.Name,
            SkuName           = "S0"
        });

        var msa = new Application("msapp", new ApplicationArgs
        {
            Oauth2AllowImplicitFlow = false,
            AvailableToOtherTenants = true,
            PublicClient            = true
        });

        var pwd = new RandomPassword("password", new RandomPasswordArgs
        {
            Length     = 16,
            MinNumeric = 1,
            MinSpecial = 1,
            MinUpper   = 1,
            MinLower   = 1
        });

        var msaSecret = new ApplicationPassword("msasecret", new ApplicationPasswordArgs
        {
            ApplicationObjectId = msa.ObjectId,
            EndDateRelative     = "8640h",
            Value = pwd.Result
        });

        var app = new AppService("app", new AppServiceArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AppServicePlanId  = appServicePlan.Id,
            AppSettings       =
            {
                { "WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl           },
                { "MicrosoftAppId",           msa.ApplicationId     },
                { "MicrosoftAppPassword",     msaSecret.Value       },
                { "LuisApiKey",               luis.PrimaryAccessKey },
            },
            HttpsOnly = true
        });

        var bot = new WebApp(botName, new WebAppArgs
        {
            DisplayName       = botName,
            MicrosoftAppId    = msa.ApplicationId,
            ResourceGroupName = resourceGroup.Name,
            Sku      = "F0",
            Location = "global",
            Endpoint = Output.Format($"https://{app.DefaultSiteHostname}/api/messages"),
            DeveloperAppInsightsApiKey        = appInsightApiKey.Key,
            DeveloperAppInsightsApplicationId = appInsights.AppId,
            DeveloperAppInsightsKey           = appInsights.InstrumentationKey
        });

        this.BotEndpoint          = bot.Endpoint;
        this.MicrosoftAppId       = msa.ApplicationId;
        this.MicrosoftAppPassword = msaSecret.Value;
    }