Пример #1
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");
    }
Пример #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 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",     "https://mikhailworkshop.blob.core.windows.net/zips/app.zip" }
            }
        });

        this.Endpoint = Output.Format($"https://{app.DefaultHostname}/api/hello");
    }
Пример #3
0
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("testResourceGroup",
                                                         new Azure.Core.ResourceGroupArgs {
            Location = "ukwest"
        });

        var serviceBusNamespace = new Azure.ServiceBus.Namespace("testServiceBusNamespace", new Azure.ServiceBus.NamespaceArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Sku = "Basic"
        });

        var messageQueue = new Azure.ServiceBus.Queue("testMessageQueue", new Azure.ServiceBus.QueueArgs
        {
            ResourceGroupName  = resourceGroup.Name,
            NamespaceName      = serviceBusNamespace.Name,
            MaxSizeInMegabytes = 1024,
            EnablePartitioning = false,
            DefaultMessageTtl  = System.Xml.XmlConvert.ToString(TimeSpan.FromSeconds(30))
        });

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

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

        var appInsights = new Azure.AppInsights.Insights("testAppInsights", new Azure.AppInsights.InsightsArgs
        {
            ResourceGroupName = resourceGroup.Name,
            RetentionInDays   = 30,
            ApplicationType   = "web",
            Location          = "uksouth"
        });

        var functionApp = new Azure.AppService.FunctionApp("testFunctionApp", new Azure.AppService.FunctionAppArgs
        {
            AppServicePlanId        = appServicePlan.Id,
            ResourceGroupName       = resourceGroup.Name,
            StorageConnectionString = functionStorage.PrimaryConnectionString,
            Version           = "~3",
            AppSettings       = { { "APPINSIGHTS_INSTRUMENTATIONKEY", appInsights.InstrumentationKey } },
            ConnectionStrings = new Azure.AppService.Inputs.FunctionAppConnectionStringsArgs
            {
                Name  = "ServiceBusConnection",
                Value = serviceBusNamespace.DefaultPrimaryConnectionString,
                Type  = "ServiceBus"
            }
        });
    }