Exemplo n.º 1
0
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("my-group");

        var group = new Group("aci", new GroupArgs
        {
            ResourceGroupName = resourceGroup.Name,
            OsType            = "Linux",
            Containers        =
            {
                new GroupContainersArgs
                {
                    Cpu    = 0.5,
                    Image  = "mcr.microsoft.com/azuredocs/aci-helloworld",
                    Memory = 1.5,
                    Name   = "hello-world",
                    Ports  =
                    {
                        new GroupContainersPortsArgs
                        {
                            Port     = 80,
                            Protocol = "TCP"
                        }
                    }
                }
            },
            IpAddressType = "public",
            DnsNameLabel  = "my-unique-string"
        });

        this.Endpoint = Output.Format($"http://{group.Fqdn}");
    }
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("my-group");

        var storageAccount = new Azure.Storage.Account("mystorage", new Azure.Storage.AccountArgs
        {
            ResourceGroupName      = resourceGroup.Name,
            AccountReplicationType = "LRS",
            AccountTier            = "Standard"
        });
    }
Exemplo n.º 3
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");
    }
Exemplo n.º 4
0
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup(Settings.ResourceGroupName);
        var storageAccount = new Azure.Storage.Account(Settings.StorageAccountName, new Azure.Storage.AccountArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AccountReplicationType = "LRS",
            AccountTier = "Standard"
        });
        var container = new Azure.Storage.Container(Settings.ContainerName, new Azure.Storage.ContainerArgs 
        {
            StorageAccountName = storageAccount.Name
        });

        this.AccountName = storageAccount.Name;
    }
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("my-group");

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

        var container = new Azure.Storage.Container("mycontainer", new Azure.Storage.ContainerArgs
        {
            Name = "files",
            StorageAccountName = storageAccount.Name
        });

        this.AccountName = storageAccount.Name;
    }
Exemplo n.º 6
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"
            }
        });
    }
Exemplo n.º 7
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");
    }
Exemplo n.º 8
0
 public MyStack()
 {
     var resourceGroup = new Azure.Core.ResourceGroup("my-group");
 }
Exemplo n.º 9
0
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("my-group");

        var network = new VirtualNetwork("server-network", new VirtualNetworkArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AddressSpaces     = { "10.0.0.0/16" },
            Subnets           =
            {
                new VirtualNetworkSubnetsArgs
                {
                    Name          = "default",
                    AddressPrefix = "10.0.1.0/24"
                }
            },
        });

        var publicIp = new PublicIp("server-ip", new PublicIpArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AllocationMethod  = "Dynamic",
        });

        var networkInterface = new NetworkInterface("server-nic", new NetworkInterfaceArgs
        {
            ResourceGroupName = resourceGroup.Name,
            IpConfigurations  =
            {
                new NetworkInterfaceIpConfigurationsArgs
                {
                    Name     = "webserveripcfg",
                    SubnetId = network.Subnets.Apply(subnets => subnets[0].Id),
                    PrivateIpAddressAllocation = "Dynamic",
                    PublicIpAddressId          = publicIp.Id,
                },
            }
        });

        var vm = new VirtualMachine("server-vm", new VirtualMachineArgs
        {
            ResourceGroupName   = resourceGroup.Name,
            NetworkInterfaceIds = { networkInterface.Id },
            VmSize = "Standard_A0",
            DeleteDataDisksOnTermination = true,
            DeleteOsDiskOnTermination    = true,
            OsProfile = new VirtualMachineOsProfileArgs
            {
                ComputerName  = "hostname",
                AdminUsername = "******",
                AdminPassword = "******",
                CustomData    =
                    @"#!/bin/bash
echo ""Hello, World!"" > index.html
nohup python -m SimpleHTTPServer 80 &",
            },
            OsProfileLinuxConfig = new VirtualMachineOsProfileLinuxConfigArgs
            {
                DisablePasswordAuthentication = false,
            },
            StorageOsDisk = new VirtualMachineStorageOsDiskArgs
            {
                CreateOption = "FromImage",
                Name         = "myosdisk1",
            },
            StorageImageReference = new VirtualMachineStorageImageReferenceArgs
            {
                Publisher = "canonical",
                Offer     = "UbuntuServer",
                Sku       = "16.04-LTS",
                Version   = "latest",
            }
        });
    }
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("my-group");

        var registry = new Registry("registry", new RegistryArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AdminEnabled      = true,
            Sku = "Standard"
        });

        var dockerImage = new Pulumi.Docker.Image("node-app", new Pulumi.Docker.ImageArgs
        {
            ImageName = Output.Format($"{registry.LoginServer}/myapp"),
            Build     = "./app",
            Registry  = new Pulumi.Docker.ImageRegistry
            {
                Server   = registry.LoginServer,
                Username = registry.AdminUsername,
                Password = registry.AdminPassword
            }
        });

        var group = new Group("aci", new GroupArgs
        {
            ResourceGroupName = resourceGroup.Name,
            OsType            = "Linux",
            Containers        =
            {
                new GroupContainersArgs
                {
                    Cpu    = 0.5,
                    Image  = dockerImage.ImageName,
                    Memory = 1.5,
                    Name   = "hello-world",
                    Ports  =
                    {
                        new GroupContainersPortsArgs
                        {
                            Port     = 80,
                            Protocol = "TCP"
                        }
                    }
                }
            },
            ImageRegistryCredentials =
            {
                new GroupImageRegistryCredentialsArgs
                {
                    Server   = registry.LoginServer,
                    Username = registry.AdminUsername,
                    Password = registry.AdminPassword
                }
            },
            IpAddressType = "public",
            DnsNameLabel  = "my-unique-name"
        }, new CustomResourceOptions {
            DeleteBeforeReplace = true
        });

        this.Endpoint = Output.Format($"http://{group.Fqdn}");
    }
Exemplo n.º 11
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"
            }
        });
    }
    public MyStack()
    {
        var resourceGroup = new Azure.Core.ResourceGroup("my-group");

        var network = new VirtualNetwork("server-network", new VirtualNetworkArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AddressSpaces     = { "10.0.0.0/16" },
            Subnets           =
            {
                new VirtualNetworkSubnetsArgs
                {
                    Name          = "default",
                    AddressPrefix = "10.0.1.0/24"
                }
            },
        });

        var publicIp = new PublicIp("server-ip", new PublicIpArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AllocationMethod  = "Dynamic",
        });

        var networkInterface = new NetworkInterface("server-nic", new NetworkInterfaceArgs
        {
            ResourceGroupName = resourceGroup.Name,
            IpConfigurations  =
            {
                new NetworkInterfaceIpConfigurationsArgs
                {
                    Name     = "webserveripcfg",
                    SubnetId = network.Subnets.Apply(subnets => subnets[0].Id),
                    PrivateIpAddressAllocation = "Dynamic",
                    PublicIpAddressId          = publicIp.Id,
                },
            }
        });

        var vm = new VirtualMachine("server-vm", new VirtualMachineArgs
        {
            ResourceGroupName   = resourceGroup.Name,
            NetworkInterfaceIds = { networkInterface.Id },
            VmSize = "Standard_A0",
            DeleteDataDisksOnTermination = true,
            DeleteOsDiskOnTermination    = true,
            OsProfile = new VirtualMachineOsProfileArgs
            {
                ComputerName  = "hostname",
                AdminUsername = "******",
                AdminPassword = "******",
                CustomData    =
                    @"#!/bin/bash
echo ""Hello, World!"" > index.html
nohup python -m SimpleHTTPServer 80 &",
            },
            OsProfileLinuxConfig = new VirtualMachineOsProfileLinuxConfigArgs
            {
                DisablePasswordAuthentication = false,
            },
            StorageOsDisk = new VirtualMachineStorageOsDiskArgs
            {
                CreateOption = "FromImage",
                Name         = "myosdisk1",
            },
            StorageImageReference = new VirtualMachineStorageImageReferenceArgs
            {
                Publisher = "canonical",
                Offer     = "UbuntuServer",
                Sku       = "16.04-LTS",
                Version   = "latest",
            }
        });

        // The public IP address is not allocated until the VM is running, so wait for that
        // resource to create, and then lookup the IP address again to report its public IP.
        this.PublicIP = Output
                        .Tuple <string, string, string>(vm.Id, publicIp.Name, resourceGroup.Name)
                        .Apply <string>(async t => {
            (_, string name, string resourceGroupName) = t;
            var ip = await Pulumi.Azure.Network.Invokes.GetPublicIP(
                new GetPublicIPArgs {
                Name = name, ResourceGroupName = resourceGroupName
            });
            return(ip.IpAddress);
        });
    }