Example #1
0
        private InputMap <string> combineAppSettings(Blob zipBlob, Account account, ArchiveFunctionAppArgs args)
        {
            var codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(zipBlob, account);
            var settings    = args.AppSettings;

            if (settings == null)
            {
                settings = new InputMap <string>();
            }
            settings.Add("WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl);
            settings.Add("WEBSITE_NODE_DEFAULT_VERSION", "~10");
            return(settings);
        }
Example #2
0
        static Task <int> Main()
        {
            return(Deployment.RunAsync(() => {
                // Create an Azure Resource Group
                var resourceGroup = new ResourceGroup("doaw20-rg");

                // Create an Azure Storage Account
                var storageAccount = new Account("doaw20st", new AccountArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    AccountReplicationType = "LRS",
                    AccountTier = "Standard",
                    //EnableHttpsTrafficOnly = true
                });

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

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

                var blob = new ZipBlob("zip", new ZipBlobArgs
                {
                    StorageAccountName = storageAccount.Name,
                    StorageContainerName = container.Name,
                    Type = "block",
                    Content = new FileArchive("../HelloFunc/bin/Debug/netcoreapp3.1/publish")
                });

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

                var app = new FunctionApp("doaw20-app", new FunctionAppArgs
                {
                    ResourceGroupName = resourceGroup.Name,
                    AppServicePlanId = appServicePlan.Id,
                    AppSettings =
                    {
                        { "runtime",                  "dotnet"    },
                        { "WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl }
                    },
                    StorageConnectionString = storageAccount.PrimaryConnectionString,
                    Version = "~3"
                });

                // Export the connection string for the storage account
                return new Dictionary <string, object?>
                {
                    { "connectionString", storageAccount.PrimaryConnectionString },
                    { "endpoint", Output.Format($"https://{app.DefaultHostname}/api/HelloPulumi?name=DevOps@Work20") }
                };
            }));
        }
Example #3
0
        public MyStack()
        {
            var projectName = Deployment.Instance.ProjectName.ToLower();
            var stackName   = Deployment.Instance.StackName;

            #region Resource Group

            var resourceGroupName = $"{projectName}-{stackName}-rg";
            var resourceGroup     = new ResourceGroup(resourceGroupName, new ResourceGroupArgs
            {
                Name = resourceGroupName
            });

            #endregion

            #region Azure Storage

            var storageAccountName = $"{projectName}{stackName}st";
            var storageAccount     = new Account(storageAccountName, new AccountArgs
            {
                Name = storageAccountName,
                ResourceGroupName      = resourceGroup.Name,
                AccountReplicationType = "LRS",
                AccountTier            = "Standard",
                AccountKind            = "StorageV2",
                EnableHttpsTrafficOnly = true
            });

            StorageConnectionString = storageAccount.PrimaryConnectionString;

            #endregion

            #region Func Blobs

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

            var lightsBlob = new Blob("lightszip", new BlobArgs
            {
                StorageAccountName   = storageAccount.Name,
                StorageContainerName = container.Name,
                Type   = "Block",
                Source = new FileArchive("../Lights/bin/Debug/netcoreapp3.1/publish")
            });
            var lightsBlobUrl = SharedAccessSignature.SignedBlobReadUrl(lightsBlob, storageAccount);

            var cacheBlob = new Blob("cachezip", new BlobArgs
            {
                StorageAccountName   = storageAccount.Name,
                StorageContainerName = container.Name,
                Type   = "Block",
                Source = new FileArchive("../Cache/bin/Debug/netcoreapp3.1/publish")
            });
            var cacheBlobUrl = SharedAccessSignature.SignedBlobReadUrl(cacheBlob, storageAccount);


            #endregion

            #region AppService Plan

            var planName       = $"{projectName}-{stackName}-plan";
            var appServicePlan = new Plan(planName, new PlanArgs
            {
                Name = planName,
                ResourceGroupName = resourceGroup.Name,
                Kind = "FunctionApp",
                Sku  = new PlanSkuArgs
                {
                    Tier = "Dynamic",
                    Size = "Y1"
                }
            });

            #endregion

            #region Lights

            var lightsName = $"{projectName}-{stackName}-func-lights";
            var lightsFunc = new FunctionApp(lightsName, new FunctionAppArgs
            {
                Name = lightsName,
                ResourceGroupName = resourceGroup.Name,
                AppServicePlanId  = appServicePlan.Id,
                AppSettings       =
                {
                    { "runtime",                  "dotnet"      },
                    { "WEBSITE_RUN_FROM_PACKAGE", lightsBlobUrl }
                },
                StorageAccountAccessKey = storageAccount.PrimaryAccessKey,
                StorageAccountName      = storageAccount.Name,
                Version = "~3"
            });

            LightsFunc = lightsFunc.DefaultHostname;

            #endregion

            #region Cache

            var cacheName = $"{projectName}-{stackName}-func-cache";
            var cacheFunc = new FunctionApp(cacheName, new FunctionAppArgs
            {
                Name = cacheName,
                ResourceGroupName = resourceGroup.Name,
                AppServicePlanId  = appServicePlan.Id,
                AppSettings       =
                {
                    { "runtime",                  "dotnet"     },
                    { "WEBSITE_RUN_FROM_PACKAGE", cacheBlobUrl }
                },
                StorageAccountAccessKey = storageAccount.PrimaryAccessKey,
                StorageAccountName      = storageAccount.Name,
                Version = "~3"
            });

            CacheFunc = cacheFunc.DefaultHostname;

            #endregion
        }