microsoftgraph / msgraph-bicep-types

Repo contains Microsoft Graph resource types to integrate with bicep templates.
MIT License
46 stars 7 forks source link

Existing syntax in language version 2 does not allow defining the same resource twice or more. #173

Open slavizh opened 2 months ago

slavizh commented 2 months ago

Issue is well known and defined here: https://github.com/Azure/bicep/issues/13674 Graph requires defining extension microsoftGraph syntax which automatically makes the language version of the compiled ARM template to version 2 and you make it compile to language version 1. So in the case with Graph resources the only workaround to the issue is to use resoruceId() syntax instead of existing syntax. Issue is opened due to conversation in https://github.com/microsoftgraph/msgraph-bicep-types/issues/126

slavizh commented 1 month ago

@dkershaw10 note that the issue exists only for Azure resources - in this case user assigned identity was defined as existing with two different syntax so it can be put as member and owner of a group. When I define Entra Application/Service principal the same way to put it as member and owner the issue is not present.

dkershaw10 commented 3 weeks ago

@slavizh please close this if your testing checks out on https://github.com/Azure/bicep/issues/13674

slavizh commented 3 weeks ago

@dkershaw10 yeah. I am planning to test if everything I have logged is fixed and close items that are fixed. Have to wait for the the next bicep release as compiling builds on my own is not my thing. Will get back once I have tested it.

slavizh commented 3 weeks ago

@dkershaw10 Unfortunately the new Bicep CLI not only made the errors worse but also the working code around existing graph resources that I had also stopped working. Getting:

"properties": { "statusCode": "InternalServerError", "serviceRequestId": null, "statusMessage": "{\"error\":{\"code\":\"MultipleErrorsOccurred\",\"message\":\"Multiple error occurred: . Please see details.\",\"details\":[{\"code\":\"InternalServerError\",\"message\":\"Encountered internal server error. Diagnostic information: timestamp '20241107T090031Z', subscription id 'f4b90a18-b44d-439b-a1b7-3c7fae8a8d54', tracking id '615361af-d1e7-4ef7-b7af-1c54f181f58b', request correlation id '615361af-d1e7-4ef7-b7af-1c54f181f58b'.\"},{\"code\":\"InternalServerError\",\"message\":\"Encountered internal server error. Diagnostic information: timestamp '20241107T090031Z', subscription id 'f4b90a18-b44d-439b-a1b7-3c7fae8a8d54', tracking id '615361af-d1e7-4ef7-b7af-1c54f181f58b', request correlation id '615361af-d1e7-4ef7-b7af-1c54f181f58b'.\"},{\"code\":\"InternalServerError\",\"message\":\"Encountered internal server error. Diagnostic information: timestamp '20241107T090031Z', subscription id 'f4b90a18-b44d-439b-a1b7-3c7fae8a8d54', tracking id '615361af-d1e7-4ef7-b7af-1c54f181f58b', request correlation id '615361af-d1e7-4ef7-b7af-1c54f181f58b'.\"},{\"code\":\"InternalServerError\",\"message\":\"Encountered internal server error. Diagnostic information: timestamp '20241107T090031Z', subscription id 'f4b90a18-b44d-439b-a1b7-3c7fae8a8d54', tracking id '615361af-d1e7-4ef7-b7af-1c54f181f58b', request correlation id '615361af-d1e7-4ef7-b7af-1c54f181f58b'.\"}]}}",

slavizh commented 3 weeks ago

Created issue https://github.com/Azure/bicep/issues/15513

dkershaw10 commented 3 weeks ago

Thanks @slavizh. This is disappointing. I've taken this problem up internally with both the BIcep and Graph engineering teams.

slavizh commented 3 weeks ago

@dkershaw10 after more testing seems the issues I have found are related to Graph resources referenced as existing. When not using Graph and extensibility there are improvements and no such issues. Another issue that I have found is https://github.com/Azure/bicep/issues/15515 . But overall the ability to reference the same resource twice is partially fixed. It works if the same resource is referenced in two different existing syntaxes ( the case I was testing with Graph - the same user assigned identity assigned as member and owner to group) but it does not work if the resource is referenced twice or more within the same existing syntax. The latter is Azure Policy and other scenarios that I have not found needed for Graph for now.