Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
location: location,
});
// Create an Azure resource (Storage Account) so we can point the CDN endpoint to it.
const storageAccount = new azure.storage.Account("storageAccount", {
resourceGroupName: resourceGroup.name,
accountTier: "Standard",
accountReplicationType: "LRS",
});
/**
* Create a Blob container in the storage account,
* to store any static files. The CDN endpoint will be pointed at the
* endpoint for this blob container.
*/
const blobContainer = new azure.storage.Container("blobContainer", {
storageAccountName: storageAccount.name,
// Make each "blob" in the container publicly accessible.
// DO NOT set this property if you are going to store sensitive files!
containerAccessType: "blob",
});
const cdnProfile = new azure.cdn.Profile("cdnProfile", {
resourceGroupName: resourceGroup.name,
// Choose an appropriate SKU to use.
// https://docs.microsoft.com/en-us/azure/cdn/cdn-features
sku: "Standard_Akamai",
});
const cdnEndpoint = new azure.cdn.Endpoint("cdnEndpoint", {
/**
* Specify a well-known name for the endpoint name,type: "block",
source: "./README.md",
});
// A plan to host the App Service
const appServicePlan = new azure.appservice.Plan("asp", {
resourceGroupName: resourceGroup.name,
kind: "App",
sku: {
tier: "Basic",
size: "B1",
},
});
// ASP.NET deployment package
const blob = new azure.storage.ZipBlob("zip", {
storageAccountName: storageAccount.name,
storageContainerName: storageContainer.name,
type: "block",
content: new pulumi.asset.FileArchive("./webapp/bin/Debug/netcoreapp2.2/publish"),
});
const clientConfig = azure.core.getClientConfig({ async: true });
const tenantId = clientConfig.then(config => config.tenantId);
const currentPrincipal = clientConfig.then(config => config.objectId);
// Key Vault to store secrets (e.g. Blob URL with SAS)
const vault = new azure.keyvault.KeyVault("vault", {
resourceGroupName: resourceGroup.name,
skuName: "standard",
tenantId: tenantId,// Create an AKS K8s cluster
const aks = new AksCluster("keda-cluster", {
resourceGroupName: resourceGroup.name,
kubernetesVersion: "1.13.5",
vmSize: "Standard_B2s",
vmCount: 3,
});
// Deploy shared components of KEDA (container registry, kedacore/keda-edge Helm chart)
const service = new KedaService("keda-edge", {
resourceGroup,
k8sProvider: aks.provider,
});
// Create the storage account and the storage queue to listen to
const storageAccount = new azure.storage.Account("kedapulumi", {
resourceGroupName: resourceGroup.name,
accountTier: "Standard",
accountReplicationType: "LRS",
});
const queue = new azure.storage.Queue("kedaqueue", {
storageAccountName: storageAccount.name,
});
// Deploy a Function App which subscribes to the Storage Queue
const app = new KedaStorageQueueHandler("queue-handler", {
resourceGroup,
service,
storageAccount,
queue,
path: "./functionapp",
});vmCount: 3,
});
// Deploy shared components of KEDA (container registry, kedacore/keda-edge Helm chart)
const service = new KedaService("keda-edge", {
resourceGroup,
k8sProvider: aks.provider,
});
// Create the storage account and the storage queue to listen to
const storageAccount = new azure.storage.Account("kedapulumi", {
resourceGroupName: resourceGroup.name,
accountTier: "Standard",
accountReplicationType: "LRS",
});
const queue = new azure.storage.Queue("kedaqueue", {
storageAccountName: storageAccount.name,
});
// Deploy a Function App which subscribes to the Storage Queue
const app = new KedaStorageQueueHandler("queue-handler", {
resourceGroup,
service,
storageAccount,
queue,
path: "./functionapp",
});
// Output the cluster name and .kube/config
export const clusterName = aks.cluster.name;
export const kubeConfig = aks.cluster.kubeConfigRaw;
export const storageAccountName = storageAccount.name;// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
import * as azure from "@pulumi/azure";
import * as pulumi from "@pulumi/pulumi";
// Create an Azure Resource Group
const resourceGroup = new azure.core.ResourceGroup("logicappdemo-rg");
// Create an Azure resource (Storage Account)
const storageAccount = new azure.storage.Account("logicappdemosa", {
resourceGroupName: resourceGroup.name,
accountReplicationType: "LRS",
accountTier: "Standard",
accountKind: "StorageV2",
});
// Cosmos DB Account
const cosmosdbAccount = new azure.cosmosdb.Account("logicappdemo-cdb", {
resourceGroupName: resourceGroup.name,
location: resourceGroup.location,
offerType: "Standard",
geoLocations: [{ location: resourceGroup.location, failoverPriority: 0 }],
consistencyPolicy: {
consistencyLevel: "Session",
},
});// use first 10 characters of the stackname as prefix for resource names
const prefix = pulumi.getStack().substring(0, 9);
const resourceGroup = new azure.core.ResourceGroup(`${prefix}-rg`, {
location: azure.Locations.WestUS2,
});
const resourceGroupArgs = {
resourceGroupName: resourceGroup.name,
location: resourceGroup.location,
};
// Storage Account name must be lowercase and cannot have any dash characters
const storageAccountName = `${prefix.toLowerCase().replace(/-/g, "")}sa`;
const storageAccount = new azure.storage.Account(storageAccountName, {
...resourceGroupArgs,
accountKind: "StorageV2",
accountTier: "Standard",
accountReplicationType: "LRS",
});
const appServicePlan = new azure.appservice.Plan(`${prefix}-asp`, {
...resourceGroupArgs,
kind: "App",
sku: {
tier: "Basic",
size: "B1",function getOrCreateGlobalStorageAccount(): azure.storage.Account {
const storageAccountId = azureConfig.get("storageAccountId");
if (storageAccountId) {
return azure.storage.Account.get("global", storageAccountId);
}
// Account name must be 24 chars or less and must be lowercase.
// https://docs.microsoft.com/en-us/azure/architecture/best-practices/naming-conventions#storage
const storageAccountName = makeSafeStorageAccountName(
createNameWithStackInfo("global" + sha1hash(pulumi.getStack()), 24, /*delim*/ ""));
return new azure.storage.Account("global", {
resourceGroupName: globalResourceGroupName,
location: location,
name: storageAccountName,
accountKind: "StorageV2",
accountTier: "Standard",
accountReplicationType: "LRS",
}, { parent: getGlobalInfrastructureResource() });
}this.storageContainer = new azure.storage.Container(`${name}-c`, {
resourceGroupName: this.resourceGroup.name,
storageAccountName: this.storageAccount.name,
containerAccessType: "private",
}, parentArgs);
this.blob = new azure.storage.ZipBlob(`${name}-b`, {
resourceGroupName: this.resourceGroup.name,
storageAccountName: this.storageAccount.name,
storageContainerName: this.storageContainer.name,
type: "block",
content: new pulumi.asset.AssetArchive(blobContent(name, handler)),
}, parentArgs);
this.codeBlobUrl = azure.storage.signedBlobReadUrl(this.blob, this.storageAccount);
this.appServicePlan = new azure.appservice.Plan(`${name}-p`, {
...resourceGroupArgs,
kind: "FunctionApp",
// https://social.msdn.microsoft.com/Forums/azure/en-US/665c365d-2b86-4a77-8cea-72ccffef216c
sku: {
tier: "Dynamic",
size: "Y1",
},
}, parentArgs);
this.functionApp = new azure.appservice.FunctionApp(`${name}-app`, {
...resourceGroupArgs,function getOrCreateGlobalStorageAccount(): azure.storage.Account {
const storageAccountId = azureConfig.get("storageAccountId");
if (storageAccountId) {
return azure.storage.Account.get("global", storageAccountId);
}
// Account name must be 24 chars or less and must be lowercase.
// https://docs.microsoft.com/en-us/azure/architecture/best-practices/naming-conventions#storage
const storageAccountName = makeSafeStorageAccountName(
createNameWithStackInfo("global" + sha1hash(pulumi.getStack()), 24, /*delim*/ ""));
return new azure.storage.Account("global", {
resourceGroupName: globalResourceGroupName,
location: location,
name: storageAccountName,
accountKind: "StorageV2",
accountTier: "Standard",
accountReplicationType: "LRS",
}, { parent: getGlobalInfrastructureResource() });
}["index.html", "404.html"].map(name =>
new azure.storage.Blob(name, {
name,
resourceGroupName: resourceGroup.name,
storageAccountName: storageAccount.name,
storageContainerName: staticWebsite.webContainerName,
type: "block",
source: `./wwwroot/${name}`,
contentType: "text/html",
}),
);