Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a prompt for the Azure location #14956

Merged
merged 1 commit into from
May 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions generators/azure-app-service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module.exports = class extends BaseBlueprintGenerator {
this.baseName = this.config.get(OptionNames.BASE_NAME);
this.buildTool = this.config.get(OptionNames.BUILD_TOOL);
this.azureAppServiceResourceGroupName = ''; // This is not saved, as it is better to get the Azure default variable
this.azureLocation = this.config.get('azureLocation');
this.azureAppServicePlan = this.config.get('azureAppServicePlan');
this.azureAppServiceName = this.config.get('azureAppServiceName');
this.azureApplicationInsightsName = this.config.get('azureApplicationInsightsName');
Expand Down Expand Up @@ -133,6 +134,7 @@ ${chalk.red('https://docs.microsoft.com/en-us/cli/azure/install-azure-cli/?WT.mc
if (err) {
this.config.set({
azureAppServiceResourceGroupName: null,
azureLocation: 'eastus',
});
this.abort = true;
this.error('Could not retrieve your Azure default configuration.');
Expand All @@ -142,6 +144,9 @@ ${chalk.red('https://docs.microsoft.com/en-us/cli/azure/install-azure-cli/?WT.mc
if (json[key].name === 'group') {
this.azureAppServiceResourceGroupName = json[key].value;
}
if (json[key].name === 'location') {
this.azureLocation = json[key].value;
}
});
if (this.azureAppServiceResourceGroupName === '') {
this.log(
Expand All @@ -150,6 +155,9 @@ ${chalk.red('https://docs.microsoft.com/en-us/cli/azure/install-azure-cli/?WT.mc
);
this.azureAppServiceResourceGroupName = '';
}
if (this.azureLocation === '') {
this.azureLocation = 'eastus';
}
}
done();
});
Expand All @@ -166,6 +174,12 @@ ${chalk.red('https://docs.microsoft.com/en-us/cli/azure/install-azure-cli/?WT.mc
message: 'Azure resource group name:',
default: this.azureAppServiceResourceGroupName,
},
{
type: 'input',
name: 'azureLocation',
message: 'Azure location:',
default: this.azureLocation,
},
{
type: 'input',
name: 'azureAppServicePlan',
Expand All @@ -188,6 +202,7 @@ ${chalk.red('https://docs.microsoft.com/en-us/cli/azure/install-azure-cli/?WT.mc

this.prompt(prompts).then(props => {
this.azureAppServiceResourceGroupName = props.azureAppServiceResourceGroupName;
this.azureLocation = props.azureLocation;
this.azureAppServicePlan = props.azureAppServicePlan;
this.azureApplicationInsightsName = props.azureApplicationInsightsName;
this.azureAppServiceName = props.azureAppServiceName;
Expand Down Expand Up @@ -290,7 +305,7 @@ ${chalk.red('https://docs.microsoft.com/en-us/cli/azure/install-azure-cli/?WT.mc
if (!servicePlanAlreadyExists) {
this.log(`Service plan '${this.azureAppServicePlan}' doesn't exist, creating it...`);
exec(
`az appservice plan create --name ${this.azureAppServicePlan} --is-linux --sku B1 --resource-group ${this.azureAppServiceResourceGroupName}`,
`az appservice plan create --name ${this.azureAppServicePlan} --is-linux --sku B1 --resource-group ${this.azureAppServiceResourceGroupName} --location ${this.azureLocation}`,
err => {
if (err) {
this.abort = true;
Expand Down Expand Up @@ -428,7 +443,7 @@ which is free for the first 30 days`);
if (err) {
this.log('Azure Application Insights instance does not exist, creating it...');
exec(
`az monitor app-insights component create --app ${this.azureApplicationInsightsName} --resource-group ${this.azureAppServiceResourceGroupName}`,
`az monitor app-insights component create --app ${this.azureApplicationInsightsName} --resource-group ${this.azureAppServiceResourceGroupName} --location ${this.azureLocation}`,
(err, stdout) => {
if (err) {
this.log(err);
Expand Down