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

Fix for issue - #5587 #5588

Conversation

dannyKBjj
Copy link
Contributor

@dannyKBjj dannyKBjj commented Dec 19, 2024

Pull Request (PR) description

MSFT_IntuneMobileAppConfigurationPolicyIOS and MSFT_IntuneAndroidManagedStoreAppConfiguration
were supposed to be pulled in favour of existing DSCResource - IntuneAppConfigurationDevicePolicy as my modules duplicated functionality. Whilst testing on our tenant we discovered the following issue: IntuneAppConfigurationDevicePolicy cannot handle 'for Intune' applications #5587

It seems that for some reason only MSFT_IntuneMobileAppConfigurationPolicyIOS was removed. This pull request adds that module back in and deletes "IntuneAppConfigurationDevicePolicy" as I believe that module is now defunct.

See
#5401
#5587

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the file CHANGELOG.md.
    Entry should say what was changed and how that affects users (if applicable), and
    reference the issue being resolved (if applicable).
  • Resource parameter descriptions added/updated in the schema.mof.
  • Resource documentation added/updated in README.md.
  • Resource settings.json file contains all required permissions.
  • Examples appropriately added/updated.
  • Unit tests added/updated.
  • New/changed code adheres to DSC Community Style Guidelines.

MSFT_IntuneMobileAppConfigurationPolicyIOS and
MSFT_IntuneAndroidManagedStoreAppConfiguration
were supposed to be pulled in favour of existing DSCResource - IntuneAppConfigurationDevicePolicy as my modules duplicated functionality. Whilst testing on our tenant we discovered the following issue:
IntuneAppConfigurationDevicePolicy cannot handle 'for Intune' applications microsoft#5587

It seems that for some reason only MSFT_IntuneMobileAppConfigurationPolicyIOS was removed. This pull request adds that module back in and deletes "IntuneAppConfigurationDevicePolicy" as I believe that module is now defunct.
@FabienTschanz
Copy link
Collaborator

@dannyKBjj Removing a resource is a breaking change. The next braking change is (I believe) in April 2025. It would be better to add the functionality to IntuneAppConfigurationDevicePoliy instead of replacing it with new resources.

@dannyKBjj
Copy link
Contributor Author

Hi, but the problem is that it is using convoluted logic to handle both. It is inconsistent with almost every other module (which all handle each workload separately) and has caused an issue, who is to say there aren't other issues? Is it possible to just submit my module alongside it and remove the bugged module at a later date? I don't really want to re-write the existing module as I believe the approach I've taken is better anyway (besides which, I have a working solution already).

@FabienTschanz
Copy link
Collaborator

@dannyKBjj Normally, if there is an issue with a module, we fix the issue in that. The name of the module comes from the separation between the two categories "Managed App" and "Managed Devices". These are also the two things we can select from in the Intune portal, which aligns more with the user experience someone would expect. We already had some cases where we didn't select the "correct" name by workload or by the resource type of what Graph would tell us but rather stay in the Intune portal realms with their naming.

It's normal for new features and functionality to appear. This happens all the time, so we have to adapt the existing resources for their new purpose. I'd wait until @ykuijs and @NikCharlebois are back and get their opinion as well. I'm just a public contributor adding my input. If you think your solution is better, we'll wait for their feedback. That's totally fine by me.

@dannyKBjj
Copy link
Contributor Author

dannyKBjj commented Dec 24, 2024

Hi, fair enough...

I don't think this is a new feature thing, this is just a fault in the way approach taken.

The issue is that the policy pulled by Get-MgBetaDeviceAppManagementMobileAppConfiguration uses the 'ID' of the targeted mobile app in the 'TargetedMobileApps' property, which is a unique value.

For reasons I don't quite understand existing IntuneAppConfigurationDevicePolicy doesn't use this ID directly, but instead uses it to retrieve the packageId/bundleId.

The problem is that for these apps iOS and Android will have share the same value, see below:

image

It then uses value this to retrieve the 'Id' in Set-Target (see below)
image

However, because the app/bundleId for iOS and Android is the same, it will simply retrieve both IDs and write them into the policy (which breaks it).

I'll see what is decided in the new year, but from my perspective, the general approach seems to be to write a module for each resource, as DSC doesn't store the platform information. In this case the module seems to be determining it by the presence of certain properties after the fact. Just seems unnecessarily complicated and out of step with most of the other modules.

I can fix the existing one, but seems fixing it is very much the hard route, when I've got 2 modules that already work? Particularly when one of those modules was never removed and the other was released, and then removed in favour of this one (which doesn't work).

Besides which; I feel my approach is more simple, easier to maintain and more consistent with the other DSC resources?

Anyway, have a great Xmas! I'll pick this up when I'm back in the New Year.

@dannyKBjj
Copy link
Contributor Author

Any further thoughts on this? Do I need to fix the existing module if I want this PR in the near-term release? To be honest if so, I may just run my modules in my environment and wait for the major update in April?

As I say, I believe the resource type approach is more consistent, easier to maintain etc. Also I don't think this is a new feature problem, I think it is a consequence of the approach taken with the previous module? If my PR will be approved I'll wait, if my PR won't be merged, then I'll reconsider...

Ideally though, it'd be included in a near-term release :-D

@ykuijs
Copy link
Member

ykuijs commented Jan 14, 2025

@dannyKBjj, thanks for submitting this PR and @FabienTschanz thanks for reviewing it.

Fabien is correct: We only release breaking changes (like removal of resources or parameters) twice a year: First releases of April or October.

In case there is an urgent issue that really breaks something, like the removal of a parameter in a cmdlet that is used, we mark the parameter as Deprecated and leave the parameter. The parameter doesn't work anymore and we write warning messages warning the users that it is deprecated. In the first Breaking change release, the parameter is then removed.

Just to summarize:

  • The IntuneMobileAppConfigurationPolicyIOS and IntuneAndroidManagedStoreAppConfiguration resource were added a while back. IntuneMobileAppConfigurationPolicyIOS was removed again, but the IntuneAndroidManagedStoreAppConfiguration resource wasn't (my bad). This was because IntuneAppConfigurationDevicePolicy was already able to configure both and therefore both resource were duplicating functionality. This has been discussed in IntuneMobileAppConfigurationPolicyIOS is not needed #5459.
  • Now that resource has a different issue. And instead of fixing it, you want to reintroduce the two resources and remove the generic one.
    Am I correct?

Just wondering:

  • Why isn't fixing the IntuneAppConfigurationDevicePolicy resource possible? If the current logic is incorrect, can be simplified or needs improvement, this would be the prefered option.
  • If we indeed decide to move forward, we should not delete the old resources but instead make them deprecated and output warnings. Get and Set methods should output warnings and do nothing. Test method should output warning and always return True.

@ricmestre, what is your opinion on this PR?

@ricmestre
Copy link
Contributor

@ykuijs My take is still the same when I said to remove the duplicated resource, it's probably better to have separate resources for this and remove the current one but as you've mentioned that would be a breaking change, so yes either the current one must be accommodated to incorporate the fixes or if the new resources are added then the current must have those warnings added.

To be honest in my solution I have the export running automatically so if I update M365DSC I'll get whatever fixes this issue so I don't mind, but for others might not be a solution to have a breaking change outside its schedule.

@ykuijs
Copy link
Member

ykuijs commented Jan 14, 2025

Ok, then lets move forward with the two resources.

Does the Android version of the resource work correctly right now or does it also need updating?

@dannyKBjj: Can you please update this PR to make the IntuneAppConfigurationDevicePolicy deprecated instead of removing it. The code should provide warnings that the resource is deprecated and do nothing else. The Readme of the resource should also say it is deprecated.

@dannyKBjj
Copy link
Contributor Author

dannyKBjj commented Jan 16, 2025

Hi yes, I can certainly do that.

I'm not sure what you mean by:

"The code should provide warnings that the resource is deprecated and do nothing else. The Readme of the resource should also say it is deprecated."

Where do I put this code, do you have an example I can refer to?

Do you mean replace/comment out the code in the old module for Get- Set etc. etc. with a Write-Verbose message to say the module is depracated? Should the message mention the new modules?

@ykuijs
Copy link
Member

ykuijs commented Jan 21, 2025

Hi yes, I can certainly do that.

I'm not sure what you mean by:

"The code should provide warnings that the resource is deprecated and do nothing else. The Readme of the resource should also say it is deprecated."

Where do I put this code, do you have an example I can refer to?

Do you mean replace/comment out the code in the old module for Get- Set etc. etc. with a Write-Verbose message to say the module is depracated? Should the message mention the new modules?

Correct, the code of the Get, Set, Test and Export methods should be replaced with a Write-Verbose message stating that the module is deprecated. The same should be added to the Readme.md of the module.

Unfortunately I do not have an example, because we do not have any other resource that is deprecated.

@ykuijs
Copy link
Member

ykuijs commented Jan 21, 2025

Please also update from Dev. A couple of files have changed

@dannyKBjj
Copy link
Contributor Author

Hi, is anyone reviewing this?

@dannyKBjj dannyKBjj mentioned this pull request Jan 27, 2025
@ykuijs
Copy link
Member

ykuijs commented Jan 27, 2025

"Please also update from Dev. A couple of files have changed" I may have messed this up? I fetched Origin in Github desktop, but now I see a conflict?!

That is correct. Recently a lot of Intune resources were updated (same issue as described in here). So please make sure the conflicts are corrected.

@ykuijs
Copy link
Member

ykuijs commented Jan 28, 2025

@dannyKBjj, can you please update with Dev?

@dannyKBjj
Copy link
Contributor Author

Done. Hopefully all OK this time?

@dannyKBjj
Copy link
Contributor Author

Now unit tests are failing!!? Again, everything is fine at my end.

@dannyKBjj
Copy link
Contributor Author

dannyKBjj commented Jan 28, 2025

Same issues with #5640
In all cases the the unit test scripts pass in my local environment.
In all cases the test/set/get/export functions are working in my live environment.

@ykuijs
Copy link
Member

ykuijs commented Jan 28, 2025

I will download your code and run the tests locally to see what is going on.

Some background info:
I am not sure what is going on here. Most of the times these kind of issues are because there are modules present on your system that are not there on the build agent......which means the tests are failing.

What I sometimes do is deleting all modules (except the default ones) from my system or using a freshly installed VM to run the tests.

@ykuijs
Copy link
Member

ykuijs commented Jan 28, 2025

When I run the tests locally, I get the exact same failing messages. Now checking what the root cause is.

@ykuijs
Copy link
Member

ykuijs commented Jan 28, 2025

These tests are failing because the resource has been deprecated and the functions always return an empty hashtable. You should update the unit test for IntuneAppConfigurationDevicePolicy to check for an empty array in each function....that is it. The rest of the tests can be removed.

@dannyKBjj
Copy link
Contributor Author

Oh wow, thanks. I'll look into it tomorrow, I could've sworn the errors were in my new modules, but maybe I was hallucinating 😂. Thanks for taking the time to look into it.

suggested to changes script to script didn't seem to work, but what I've done instead allows it to pass, but leaves original code intact (but commented out). Edits should be obvious. Hopefully this is good enough!
@dannyKBjj
Copy link
Contributor Author

tried checking for @{} as returned by the function, that didn't seem to work - strange errors along lines of - expected hashtable, but got hashtable errors. Commented out tests instead and checked for $null where applicable - the script now passes and can easily be reverted should anyone wish to.

@dannyKBjj
Copy link
Contributor Author

hi, all checks passed on this pull a couple of weeks ago, is it possible that someone could review and (hopefully) merge?

@dannyKBjj
Copy link
Contributor Author

hi, still need a review on this please?

recent changes to Export not reflected in this PR. Updating it so expedite module acceptance.
@dannyKBjj
Copy link
Contributor Author

Has issue #5588 been fixed somehow? I was looking at simply fixing the module as perhaps that is an easier merge, but now I am going through my steps to reproduce the issue and it seems to be working properly. I checked the code and the logic looks good. I can't find another pull request related to this though.

@dannyKBjj
Copy link
Contributor Author

It looks to me like I may as well close this PR?

@dannyKBjj
Copy link
Contributor Author

Turns out the issue might've been that you can add the same app twice in the Apps blade. As the original module goes off the name it will pull both bundleIDs. My module didn't have the issue as it goes directly off the bundleID. All in all, it seems like a bug with the Apps blade and not the module, so I'm closing this PR.

@dannyKBjj dannyKBjj closed this Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IntuneAppConfigurationDevicePolicy cannot handle 'for Intune' applications
4 participants