Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stack72/a9fde0be407181af02aa6c09fb166372 to your computer and use it in GitHub Desktop.
Save stack72/a9fde0be407181af02aa6c09fb166372 to your computer and use it in GitHub Desktop.
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
import * as docker from "@pulumi/docker";
import * as pulumi from "@pulumi/pulumi";
import * as containerregistry from "@pulumi/azure-native/containerregistry";
import * as operationalinsights from "@pulumi/azure-native/operationalinsights";
import * as resources from "@pulumi/azure-native/resources";
import * as app from "@pulumi/azure-native/app";
const resourceGroup = new resources.ResourceGroup("rg");
const workspace = new operationalinsights.Workspace("loganalytics", {
resourceGroupName: resourceGroup.name,
sku: {
name: "PerGB2018",
},
retentionInDays: 30,
});
const workspaceSharedKeys = operationalinsights.getSharedKeysOutput({
resourceGroupName: resourceGroup.name,
workspaceName: workspace.name,
});
const kubeEnv = new app.ManagedEnvironment("env", {
resourceGroupName: resourceGroup.name,
appLogsConfiguration: {
destination: "log-analytics",
logAnalyticsConfiguration: {
customerId: workspace.customerId,
sharedKey: workspaceSharedKeys.apply(r => r.primarySharedKey!),
},
},
});
// const registry = new containerregistry.Registry("registry", {
// resourceGroupName: resourceGroup.name,
// sku: {
// name: "Basic",
// },
// adminUserEnabled: true,
// });
// const credentials = containerregistry.listRegistryCredentialsOutput({
// resourceGroupName: resourceGroup.name,
// registryName: registry.name,
// });
// const adminUsername = credentials.apply(c => c.username!);
// const adminPassword = credentials.apply(c => c.passwords![0].value!);
//
// const customImage = "node-app";
// const myImage = new docker.Image(customImage, {
// imageName: pulumi.interpolate`${registry.loginServer}/${customImage}:v1.0.0`,
// build: { context: `./${customImage}` },
// registry: {
// server: registry.loginServer,
// username: adminUsername,
// password: adminPassword,
// },
// });
const containerApp = new app.ContainerApp("app", {
resourceGroupName: resourceGroup.name,
managedEnvironmentId: kubeEnv.id,
configuration: {
ingress: {
external: true,
targetPort: 80,
},
// registries: [{
// server: registry.loginServer,
// username: adminUsername,
// passwordSecretRef: "pwd",
// }],
// secrets: [{
// name: "pwd",
// value: adminPassword,
// }],
},
template: {
containers: [{
name: "myapp",
image: "nginx:latest",
}],
},
});
export const url = pulumi.interpolate`https://${containerApp.configuration.apply(c => c?.ingress?.fqdn)}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment