示例#1
0
    public static Output <string> Run()
    {
        // Read a list of target locations from the config file:
        // Expecting a comma-separated list, e.g., "westus,eastus,westeurope"
        var locations = new Config().Require("locations").Split(",");

        var resourceGroup = new ResourceGroup("cosmosvms-rg", new ResourceGroupArgs {
            Location = locations[0]
        });

        var vmss = new CosmosApp("vmss", new CosmosAppArgs
        {
            ResourceGroup = resourceGroup,
            Locations     = locations,
            DatabaseName  = "pricedb",
            ContainerName = "prices",
            Factory       = new Builder(resourceGroup).BuildVMScaleSetApp,
        });

        return(Output.Format($"{vmss.Endpoint}/cosmos"));
    }
示例#2
0
    public static IDictionary <string, object> Run()
    {
        // Read a list of target locations from the config file:
        // Expecting a comma-separated list, e.g., "westus,eastus,westeurope"
        var locations = new Config().Require("locations").Split(",");

        var resourceGroup = new ResourceGroup("cosmosfunctions-rg", new ResourceGroupArgs {
            Location = locations[0]
        });

        var app = new CosmosApp("functions", new CosmosAppArgs
        {
            ResourceGroup = resourceGroup,
            Locations     = locations,
            DatabaseName  = "pricedb",
            ContainerName = "prices",
            Factory       = global => region =>
            {
                var connectionString = global.CosmosAccount.ConnectionStrings.Apply(cs => cs[0]);
                var func             = new ArchiveFunctionApp($"afa-{region.Location}", new ArchiveFunctionAppArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    Location          = region.Location,
                    Archive           = new FileArchive("./app/bin/Debug/netcoreapp2.2/publish"),
                    AppSettings       =
                    {
                        { "CosmosDBConnection", connectionString },
                    },
                },
                                                              global.Options);

                return(new AzureEndpoint(func.AppId));
            },
        });

        return(new Dictionary <string, object>
        {
            { "functionsEndpoint", Output.Format($"{app.Endpoint}/cosmos") }
        });
    }
示例#3
0
    public static Output <string> Run()
    {
        // Read a list of target locations from the config file:
        // Expecting a comma-separated list, e.g., "westus,eastus,westeurope"
        var locations = new Pulumi.Config().Require("locations").Split(",");

        var resourceGroup = new ResourceGroup("cosmosaci-rg", new ResourceGroupArgs {
            Location = locations[0]
        });

        var app = new CosmosApp("aci", new CosmosAppArgs
        {
            ResourceGroup = resourceGroup,
            Locations     = locations,
            DatabaseName  = "pricedb",
            ContainerName = "prices",
            Factory       = global =>
            {
                var registry = new Registry("global", new RegistryArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    AdminEnabled      = true,
                    Sku = "Premium",
                }, global.Options);

                var dockerImage = new Image("node-app", new ImageArgs
                {
                    ImageName = Output.Format($"{registry.LoginServer}/mynodeapp:v1.0.0"),
                    Build     = "./container",
                    Registry  = new ImageRegistry
                    {
                        Server   = registry.LoginServer,
                        Username = registry.AdminUsername,
                        Password = registry.AdminPassword,
                    },
                }, new ComponentResourceOptions {
                    Parent = registry
                });

                return(region =>
                {
                    var connectionString = global.CosmosAccount.ConnectionStrings.Apply(cs => cs[0]);
                    var group = new Group($"aci-{region.Location}", new GroupArgs
                    {
                        ResourceGroupName = resourceGroup.Name,
                        Location = region.Location,
                        ImageRegistryCredentials =
                        {
                            new GroupImageRegistryCredentialArgs
                            {
                                Server = registry.LoginServer,
                                Username = registry.AdminUsername,
                                Password = registry.AdminPassword,
                            }
                        },
                        OsType = "Linux",
                        Containers =
                        {
                            new GroupContainerArgs
                            {
                                Cpu = 0.5,
                                Image = dockerImage.ImageName,
                                Memory = 1.5,
                                Name = "hello-world",
                                Ports =
                                {
                                    new GroupContainerPortArgs
                                    {
                                        Port = 80,
                                        Protocol = "TCP",
                                    }
                                },
                                EnvironmentVariables =
                                {
                                    { "ENDPOINT",   global.CosmosAccount.Endpoint           },
                                    { "MASTER_KEY", global.CosmosAccount.PrimaryMasterKey   },
                                    { "DATABASE",   global.Database.Name                    },
                                    { "COLLECTION", global.Container.Name                   },
                                    { "LOCATION",   region.Location                         },
                                },
                            },
                        },
                        IpAddressType = "public",
                        DnsNameLabel = $"acishop-{region.Location}",
                    }, global.Options);

                    return new ExternalEndpoint(group.Fqdn);
                });
            }
        });

        return(Output.Format($"{app.Endpoint}/cosmos"));
    }