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

Bug report - naming conventions for resource deletion #903

Open
Freakling opened this issue Nov 1, 2024 · 1 comment
Open

Bug report - naming conventions for resource deletion #903

Freakling opened this issue Nov 1, 2024 · 1 comment
Assignees
Labels

Comments

@Freakling
Copy link

Describe the bug
The code seems a bit complicated, but from what I can figure out AzOps deletion of custom resources seems to require following the AzOps naming convention for resolving the diffdeletedfiles to "statepath", that is resourceprovider+resource+childpath
i.e microsoft.authoriation_policydefinitions_somename.json/bicep.

I believe this is a product of how AzOpsScopes are built, see the below link for more information.

return (Join-Path (Join-Path $rgpath -ChildPath "$(Get-PSFConfigValue -FullName 'AzOps.Core.AutoGeneratedTemplateFolderPath')".ToLower()) -ChildPath ($this.ResourceProvider + "_" + $this.Resource + "-" + $childpath).ToLower())

It would be great if this is more obvious in the wiki, perhaps some statement that azops requires the naming convention to be followed, and also a separate wiki page detailing exactly how azops builds the file names and a disclaimers that they need to be followed if resource deletion is wanted.
https://github.com/azure/azops/wiki/ResourceDeletion

A good bonus to this might be that the validate.yaml could screen for naming convention resource type prefix.

Steps to reproduce

  1. Create a file with naming that does not follow azops standards
  2. deploy file
  3. delete file
  4. nothing gets deleted
@Jefajers Jefajers self-assigned this Dec 16, 2024
@Jefajers
Copy link
Member

Hi @Freakling, when enabling Custom Template Resource Deletion by setting "Core.CustomTemplateResourceDeletion": true the intent is to enable deletion of files regardless of file base name.

Meaning a file called name1.bicep or name2.json are expected to both be processed and deleted, given the resource supports whatif.

I have attempted to re-create the scenario you mention unsuccessfully, what I have however found is there seems to be some change in the underlying Az.PowerShell module in regards to resource retrieval for policyDefinitions resulting in the module throwing when executing deletion, however the deletion is still successful (#908).

Would it be possible for you to share the template you are attempting to delete along with AzOps version and Settings to enable me to further troubleshoot the issue you are experiencing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants