public ArchiveFunctionApp(string name, ArchiveFunctionAppArgs args, ResourceOptions?options = null)
        : base("examples:azure:ArchiveFunctionApp", name, options)
    {
        var opts = CustomResourceOptions.Merge(options, new CustomResourceOptions {
            Parent = this
        });

        var storageAccount = new Account($"sa{args.Location}", new AccountArgs
        {
            ResourceGroupName      = args.ResourceGroupName,
            Location               = args.Location,
            AccountReplicationType = "LRS",
            AccountTier            = "Standard",
        }, opts);

        var appServicePlan = new Plan($"asp-{args.Location}", new PlanArgs
        {
            ResourceGroupName = args.ResourceGroupName,
            Location          = args.Location,
            Kind = "FunctionApp",
            Sku  = new PlanSkuArgs
            {
                Tier = "Dynamic",
                Size = "Y1",
            },
        }, opts);

        var container = new Container($"zips-{args.Location}", new ContainerArgs
        {
            StorageAccountName  = storageAccount.Name,
            ContainerAccessType = "private",
        }, opts);

        var blob = new ZipBlob($"zip-{args.Location}", new ZipBlobArgs
        {
            StorageAccountName   = storageAccount.Name,
            StorageContainerName = container.Name,
            Type    = "block",
            Content = args.Archive,
        }, opts);

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

        args.AppSettings.Add("runtime", "dotnet");
        args.AppSettings.Add("WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl);

        var app = new FunctionApp($"app-{args.Location}", new FunctionAppArgs
        {
            ResourceGroupName       = args.ResourceGroupName,
            Location                = args.Location,
            AppServicePlanId        = appServicePlan.Id,
            AppSettings             = args.AppSettings,
            StorageConnectionString = storageAccount.PrimaryConnectionString,
            Version = "~2",
        }, opts);

        this.AppId = app.Id;
    }
Exemplo n.º 2
0
    public ArchiveFunctionApp(string name, ArchiveFunctionAppArgs args, ComponentResourceOptions?options = null)
        : base("examples:azure:ArchiveFunctionApp", name, options)
    {
        var opts = new CustomResourceOptions {
            Parent = this
        };

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

        var appServicePlan = new Plan("asp", new PlanArgs
        {
            ResourceGroupName = args.ResourceGroupName,
            Kind = "FunctionApp",
            Sku  = new PlanSkuArgs
            {
                Tier = "Dynamic",
                Size = "Y1",
            },
        }, opts);

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

        var blob = new Blob("zip", new BlobArgs
        {
            StorageAccountName   = storageAccount.Name,
            StorageContainerName = container.Name,
            Type   = "Block",
            Source = args.Archive
        }, opts);

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

        var app = new FunctionApp("app", new FunctionAppArgs
        {
            ResourceGroupName = args.ResourceGroupName,
            AppServicePlanId  = appServicePlan.Id,
            AppSettings       =
            {
                { "runtime",                  "dotnet"    },
                { "WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl },
            },
            StorageConnectionString = storageAccount.PrimaryConnectionString,
            Version = "~2"
        }, opts);
    }