Error "The parameter location has an invalid value" when deploying bicep file, even if the bicep does not contain any location info.
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
0.4.1318
**Describe the bug**
This has a bit of a timeline because I've been struggling with it for about a week now... I'll describe it in bullet points.
Context: I'm trying to setup a pipeline for a Function App within a service plan. The original attempt was with ARM templates, after which I switched to bicep.
- All my resources are located in West-Europe.
- Templates have been generated from the Azure Portal export function, based on my manually created resources in the development environment.
- My storage/insights/cosmos db/... resources all had the location set to "westeurope" in a location parameter, and were deployed perfectly.
- My Function App resource deployment always fails with the error message "The parameter location has an invalid value".
The things I've tried:
- Changing location from westeurope to West Europe, to resourceGroup().location
- Using these different location values both in hardcoded values as well as param values
- Using a param with these different values injected from the AZ CLI call
Next things I've tried (and this is where it gets weird)
- Based on [Issue #4815](https://github.com/Azure/bicep/issues/4815) I've tried entering a random value. That's when I receive this error message:
```
ERROR: {'code': 'LocationNotAvailableForResourceType', 'message': "
The provided location 'test' is not available for resource type 'Microsoft.Web/sites'.
List of available regions for the resource type is '
southcentralus,
msftwestus,
msfteastus,
msfteastasia,
msftnortheurope,
eastus2stage,
centralusstage,
southafricanorth,
westus,
australiaeast,
brazilsouth,
southeastasia,
centralus,
japanwest,
centralindia,
uksouth,
canadaeast,
koreacentral,
francecentral,
northeurope,
westus2,
eastus,
westindia,
eastus2,
australiacentral,
germanywestcentral,
norwayeast,
uaenorth,
switzerlandnorth,
northcentralus,
ukwest,
australiasoutheast,
koreasouth,
canadacentral,
westeurope,
southindia,
westcentralus,
eastasiastage,
northcentralusstage,
westus3,
eastasia,
japaneast,
jioindiawest
'."}
```
The value westeurope is present in that list... But gives an invalid location error when I enter it...
- I've then tried an entirely different value, eg. northeurope, but that of course fails because the serverfarm is located in westeurope and the Function App needs to be in the same region.
- I've then tried to remove the resource entirely from the bicep, and create the function app through Azure CLI, which works, but I still need the bicep templates to create the identity provider coupled to my B2C tenant. That template has no location info whatsoever present, but STILL this gives me the same error message of "parameter location has an invalid value".
**Additional context**
The original template for the function app was this:
```
param function_app_name string
param serverfarmid string
param location string = 'westeurope'
resource function_app_name_resource 'Microsoft.Web/sites@2021-03-01' = {
name: function_app_name
location: location
kind: 'functionapp'
properties: {
enabled: true
hostNameSslStates: [{
name: '${function_app_name}.azurewebsites.net'
sslState: 'Disabled'
hostType: 'Standard'
}{
name: '${function_app_name}.scm.azurewebsites.net'
sslState: 'Disabled'
hostType: 'Repository'
}
]
serverFarmId: serverfarmid
reserved: false
isXenon: false
hyperV: false
siteConfig: {
numberOfWorkers: 1
acrUseManagedIdentityCreds: false
alwaysOn: false
http20Enabled: false
functionAppScaleLimit: 200
minimumElasticInstanceCount: 1
}
scmSiteAlsoStopped: false
clientAffinityEnabled: false
clientCertEnabled: false
clientCertMode: 'Required'
hostNamesDisabled: false
customDomainVerificationId: 'D66FAC927CFA4699149BB60D0F4CC216EF611163A384850BDEEE5B52D35CCF63'
containerSize: 1536
dailyMemoryTimeQuota: 0
httpsOnly: true
redundancyMode: 'None'
storageAccountRequired: false
keyVaultReferenceIdentity: 'SystemAssigned'
}
}
```
And the latest used template is this:
```
param function_app_site_name string
resource function_app 'Microsoft.Web/sites@2021-03-01' existing = {
name: function_app_site_name
}
resource sites_functions_name_ftp 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2021-03-01' = {
parent: function_app
name: 'ftp'
properties: {
allow: true
}
}
resource sites_functions_name_scm 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2021-03-01' = {
parent: function_app
name: 'scm'
properties: {
allow: true
}
}
resource sites_functions_name_web 'Microsoft.Web/sites/config@2021-03-01' = {
parent: function_app
name: 'web'
properties: {
numberOfWorkers: 1
defaultDocuments: [
'Default.htm'
'Default.html'
'Default.asp'
'index.htm'
'index.html'
'iisstart.htm'
'default.aspx'
'index.php'
]
netFrameworkVersion: 'v6.0'
requestTracingEnabled: false
remoteDebuggingEnabled: false
remoteDebuggingVersion: 'VS2019'
httpLoggingEnabled: false
acrUseManagedIdentityCreds: false
logsDirectorySizeLimit: 35
detailedErrorLoggingEnabled: false
publishingUsername: '$iim-swoove-API'
scmType: 'None'
use32BitWorkerProcess: true
webSocketsEnabled: false
alwaysOn: false
managedPipelineMode: 'Integrated'
virtualApplications: [
{
virtualPath: '/'
physicalPath: 'site\\wwwroot'
preloadEnabled: false
}
]
loadBalancing: 'LeastRequests'
experiments: {
rampUpRules: []
}
autoHealEnabled: false
vnetRouteAllEnabled: false
vnetPrivatePortsCount: 0
cors: {
allowedOrigins: [
'https://portal.azure.com'
]
supportCredentials: false
}
localMySqlEnabled: false
ipSecurityRestrictions: [
{
ipAddress: 'Any'
action: 'Allow'
priority: 1
name: 'Allow all'
description: 'Allow all access'
}
]
scmIpSecurityRestrictions: [
{
ipAddress: 'Any'
action: 'Allow'
priority: 1
name: 'Allow all'
description: 'Allow all access'
}
]
scmIpSecurityRestrictionsUseMain: false
http20Enabled: false
minTlsVersion: '1.2'
scmMinTlsVersion: '1.0'
ftpsState: 'AllAllowed'
preWarmedInstanceCount: 0
functionAppScaleLimit: 200
functionsRuntimeScaleMonitoringEnabled: false
minimumElasticInstanceCount: 1
azureStorageAccounts: {}
}
}
resource sites_functions_name_azurewebsites_net 'Microsoft.Web/sites/hostNameBindings@2021-03-01' = {
parent: function_app
name: '${function_app_site_name}.azurewebsites.net'
properties: {
siteName: function_app_site_name
hostNameType: 'Verified'
}
}
resource api_authentication_settings 'Microsoft.Web/sites/config@2021-03-01' = {
name: 'authsettingsV2'
parent: function_app
properties: {
identityProviders: {
azureActiveDirectory: {
enabled: true
registration: {
clientId: ''
clientSecretSettingName: 'MICROSOFT_PROVIDER_AUTHENTICATION_SECRET'
}
validation: {
allowedAudiences: [
'https://'
]
}
}
}
}
}
```
Contributor guide
Research direction
Start by reproducing the deployment with the two Microsoft.Web/sites Bicep templates shown and the Azure CLI values described. Compare the behavior of the Function App resource with the existing site and child config resources; done means the templates deploy successfully in westeurope without the invalid location error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100