-
Notifications
You must be signed in to change notification settings - Fork 753
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
Deployment fails with incorrect segment lengths error when using the name property of the parent resource for a module to deploy its child object. #5269
Comments
+1 |
Segmented resource names ( Instead, we'd encourage you to always get a symbolic reference to the resource via the |
@alex-frankel may be create linter rule for this as this breaks without people knowing it will. Returning different name value depending on the hierarchy of the resource is not consistent behavior. |
We agree that this is confusing. We are actually planning to eventually deprecate support for |
Hi doubleyouvdb, this issue has been marked as stale because it was labeled as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thanks for contributing to bicep! 😄 🦾 |
Bicep version
Bicep CLI version 0.4.1 (e238759)
Bicep Visual Studio Code Plugin: v0.4.1008 Preview
Describe the bug
Deployment fails with incorrect segment lengths error when using the name property of the parent resource as a parameter for a module to deploy a child object.
An error occurred while deploying this offering. Error: 2021-11-25T11:56:09.2892079Z �[96m | �[91m11:56:08 - The deployment 'azDeploy-211125-1154-lz-cosmos-db' 2021-11-25T11:56:09.2892979Z �[96m | �[91mfailed with error(s). Showing 2 out of 2 error(s). Status 2021-11-25T11:56:09.2893872Z �[96m | �[91mMessage: At least one resource deployment operation failed. 2021-11-25T11:56:09.2894766Z �[96m | �[91mPlease list deployment operations for details. Please see 2021-11-25T11:56:09.2895697Z �[96m | �[91mhttps://aka.ms/DeployOperations for usage details. (Code: 2021-11-25T11:56:09.2896965Z �[96m | �[91mDeploymentFailed) - { "error": { "code": 2021-11-25T11:56:09.2897922Z �[96m | �[91m"InvalidTemplate", "message": "Deployment template 2021-11-25T11:56:09.2898792Z �[96m | �[91mvalidation failed: 'The template resource 2021-11-25T11:56:09.2918460Z �[96m | �[91m'sql-bdcaujwcntg7etnwr1/sql-bdcaujwcntg7etnwr1/documents/nothrougput' for type 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers' at line '1' and column '1585' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name. Please see https://aka.ms/arm-template/#resources for usage details.'.", "additionalInfo": [ { "type": "TemplateViolation", "info": { "lineNumber": 1, "linePosition": 1585, "path": "properties.template.resources[0].type" } } ] } } (Code:BadRequest) - { "error": { "code": "InvalidTemplate", "message": "Deployment template validation failed: 'The template resource 'sql-bdcaujwcntg7etnwr1/sql-bdcaujwcntg7etnwr1/documents/operations' for type 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers' at line '1' and column '1586' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name. Please see https://aka.ms/arm-template/#resources for usage details.'.", "additionalInfo": [ { "type": "TemplateViolation", "info": { "lineNumber": 1, "linePosition": 1586, "path": "properties.template.resources[0].type" } } ] } } (Code:BadRequest) Status Message: At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details. (Code: DeploymentFailed) - { "status": "Failed", "error": { "code": "ResourceDeploymentFailure", "message": "The resource operation completed with terminal provisioning state 'Failed'.", "details": [ { "code": "DeploymentFailed", "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.", "details": [ { "code": "Conflict", "message": "{ "status": "Failed", "error": { "code": "ResourceDeploymentFailure", "message": "The resource operation completed with terminal provisioning state 'Failed'.", "details": [ { "code": "DeploymentFailed", "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.", "details": [ { "code": "BadRequest", "message": "{ "error": { "code": "InvalidTemplate", "message": "Deployment template validation failed: 'The template resource 'sql-bdcaujwcntg7etnwr1/sql-bdcaujwcntg7etnwr1/documents/nothrougput' for type 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers' at line '1' and column '1585' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name. Please see https://aka.ms/arm-template/#resources for usage details.'.", "additionalInfo": [ { "type": "TemplateViolation", "info": { "lineNumber": 1, "linePosition": 1585, "path": "properties.template.resources[0].type" } } ] } }" }, { "code": "BadRequest", "message": "{ "error": { "code": "InvalidTemplate", "message": "Deployment template validation failed: 'The template resource 'sql-bdcaujwcntg7etnwr1/sql-bdcaujwcntg7etnwr1/documents/operations' for type 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers' at line '1' and column '1586' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name. Please see https://aka.ms/arm-template/#resources for usage details.'.", "additionalInfo": [ { "type": "TemplateViolation", "info": { "lineNumber": 1, "linePosition": 1586, "path": "properties.template.resources[0].type" } } ] } }" } ] } ] } }" } ] } ] } } (Code:Conflict) CorrelationId: a151ed8f-dff0-42ff-9257-34c96161d601
To Reproduce
In the parent bicep file, which calls the module for the child object:
Content of the module for the child object:
Deploying of the child object will result in the incorrect segment error above, as name will be actually '${cosmosDatabaseName}/${cosmosDatabaseName}/${sqlDatabase.name}' , which is incorrect.
To workaround
Workaround is to create additional existing resource 'cosmosAccount ' and adapting the name and adding the parent property in 'sqlDatabaseRes '. This way we can set sqlDatabaseRes.name as parameter sqlDatabaseName while also keeping the content the same in the module file.
The text was updated successfully, but these errors were encountered: