Skip to content

Commit

Permalink
Merge pull request #234 from nitrictech/feature/azure-container-app
Browse files Browse the repository at this point in the history
Transition to use Azure container apps.
  • Loading branch information
jyecusch authored Nov 5, 2021
2 parents bca443e + 1679bba commit b3563f8
Show file tree
Hide file tree
Showing 8 changed files with 500 additions and 235 deletions.
6 changes: 4 additions & 2 deletions packages/plugins/azure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"@nitric/cli-common": "workspace:*",
"@oclif/command": "^1",
"@oclif/config": "^1",
"@pulumi/azure-native": "^1.1.0",
"@pulumi/azure-native": "^1.44.0",
"@pulumi/azuread": "^5.7.0",
"@pulumi/docker": "^3.0.0",
"@pulumi/pulumi": "^3.5.1",
"@pulumi/random": "^4.3.1",
"api-spec-converter": "^2.11.4",
"cli-ux": "^5.5.1",
"cron-parser": "^3.2.0",
Expand Down Expand Up @@ -68,6 +70,6 @@
"prepack": "rimraf -rf lib && tsc -p tsconfig.build.json && oclif-dev manifest && oclif-dev readme",
"test": "tsc --emitDeclarationOnly && jest --passWithNoTests",
"set:version": "npm version --version-git-tag false",
"npm:publish": "yarn npm publish --access restricted --tolerate-republish"
"npm:publish": "yarn npm publish --access public --tolerate-republish"
}
}
168 changes: 63 additions & 105 deletions packages/plugins/azure/src/commands/deploy/azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,110 +25,74 @@ import {
} from '@nitric/cli-common';
import path from 'path';
import { Deploy } from '../../tasks/deploy';
import { AppServicePlan } from '../../types';

const SUPPORTED_REGIONS = [
'eastus',
'eastus2',
'southcentralus',
'westus2',
'australiaeast',
'southeastasia',
//'eastus',
//'eastus2',
//'southcentralus',
//'westus2',
//'australiaeast',
//'southeastasia',
'northeurope',
'uksouth',
'westeurope',
'centralus',
'northcentralus',
'westus',
'southafricanorth',
'centralindia',
'eastasia',
'japaneast',
'koreacentral',
//'uksouth',
//'westeurope',
//'centralus',
//'northcentralus',
//'westus',
//'southafricanorth',
//'centralindia',
//'eastasia',
//'japaneast',
//'koreacentral',
'canadacentral',
'francecentral',
'germanywestcentral',
'norwayeast',
'switzerlandnorth',
'uaenorth',
'brazilsouth',
'centralusstage',
'eastusstage',
'eastus2stage',
'northcentralusstage',
'southcentralusstage',
'westusstage',
'westus2stage',
'asia',
'asiapacific',
'australia',
'brazil',
'canada',
'europe',
'global',
'india',
'japan',
'uk',
'unitedstates',
'eastasiastage',
'southeastasiastage',
'centraluseuap',
'eastus2euap',
'westcentralus',
'westus3',
'southafricawest',
'australiacentral',
'australiacentral2',
'australiasoutheast',
'japanwest',
'koreasouth',
'southindia',
'westindia',
'canadaeast',
'francesouth',
'germanynorth',
'norwaywest',
'switzerlandwest',
'ukwest',
'uaecentral',
'brazilsoutheast',
//'francecentral',
//'germanywestcentral',
//'norwayeast',
//'switzerlandnorth',
//'uaenorth',
//'brazilsouth',
//'centralusstage',
//'eastusstage',
//'eastus2stage',
//'northcentralusstage',
//'southcentralusstage',
//'westusstage',
//'westus2stage',
//'asia',
//'asiapacific',
//'australia',
//'brazil',
//'canada',
//'europe',
//'global',
//'india',
//'japan',
//'uk',
//'unitedstates',
//'eastasiastage',
//'southeastasiastage',
//'centraluseuap',
//'eastus2euap',
//'westcentralus',
//'westus3',
//'southafricawest',
//'australiacentral',
//'australiacentral2',
//'australiasoutheast',
//'japanwest',
//'koreasouth',
//'southindia',
//'westindia',
//'canadaeast',
//'francesouth',
//'germanynorth',
//'norwaywest',
//'switzerlandwest',
//'ukwest',
//'uaecentral',
//'brazilsoutheast',
];

const APPSERVICE_PLANS: Record<string, AppServicePlan> = {
'Free-F1': {
tier: 'Free',
size: 'F1',
},
'Shared-D1': {
tier: 'Shared',
size: 'D1',
},
'Basic-B1': {
tier: 'Basic',
size: 'B1',
},
'Basic-B2': {
tier: 'Basic',
size: 'B2',
},
'Basic-B3': {
tier: 'Basic',
size: 'B3',
},
'Standard-S1': {
tier: 'Standard',
size: 'S1',
},
'Standard-S2': {
tier: 'Standard',
size: 'S2',
},
'Standard-S3': {
tier: 'Standard',
size: 'S3',
},
};

/**
* Deploy a stack to Microsoft Azure
*
Expand All @@ -146,11 +110,6 @@ export default class AzureDeploy extends BaseCommand {
char: 'r',
description: 'azure region to deploy to',
}),
plan: flags.enum({
options: Object.keys(APPSERVICE_PLANS),
char: 'p',
description: 'azure appservice plan tier',
}),
file: flags.string({
char: 'f',
default: 'nitric.yaml',
Expand Down Expand Up @@ -197,7 +156,7 @@ export default class AzureDeploy extends BaseCommand {
promptFlags = await inquirer.prompt(prompts);
}

const { file, region, orgName, adminEmail, plan } = { ...flags, ...promptFlags };
const { file, region, orgName, adminEmail } = { ...flags, ...promptFlags };

if (!region) {
throw new Error('Region must be provided, for prompts use the --guided flag');
Expand All @@ -222,7 +181,6 @@ export default class AzureDeploy extends BaseCommand {
region,
orgName,
adminEmail,
servicePlan: APPSERVICE_PLANS[plan],
}),
),
],
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/azure/src/resources/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import * as pulumi from '@pulumi/pulumi';
import { NitricAPITarget, StackAPI, constants } from '@nitric/cli-common';
import { resources, apimanagement } from '@pulumi/azure-native';
import { OpenAPIV3 } from 'openapi-types';
import { NitricComputeAzureAppService } from '.';
import { NitricComputeAzureContainerApp } from '.';

interface NitricApiAzureApiManagementArgs {
resourceGroup: resources.ResourceGroup;
orgName: string;
adminEmail: string;
api: StackAPI;
services: NitricComputeAzureAppService[];
services: NitricComputeAzureContainerApp[];
}

type method = 'get' | 'post' | 'put' | 'update' | 'delete' | 'patch';
Expand Down Expand Up @@ -117,7 +117,7 @@ export class NitricApiAzureApiManagement extends pulumi.ComponentResource {
<policies>
<inbound>
<base />
<set-backend-service base-url="https://${func.webapp.defaultHostName}" />
<set-backend-service base-url="https://${func.containerApp.latestRevisionFqdn}" />
</inbound>
<backend>
<base />
Expand Down
Loading

0 comments on commit b3563f8

Please sign in to comment.