diff --git a/generators/azure-app-service/index.js b/generators/azure-app-service/index.js index ead44886e4c..a49004659d8 100644 --- a/generators/azure-app-service/index.js +++ b/generators/azure-app-service/index.js @@ -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'); @@ -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.'); @@ -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( @@ -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(); }); @@ -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', @@ -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; @@ -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; @@ -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);