-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add support for updating Az modules with parameter AzureModuleClass #6
Conversation
… use for this script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks great. Please address the comment.
@AnatoliB changes made as per requests |
Thank you, @ayoung012. |
They are not tagged differently on the PS gallery. It will have to be name filtered. Is it possible to install the 'Az' module and 'AzureRM' to an automation account in its entirety? If so should these be filtered too? I see the filter checking for the following: Anything I have missed? |
This is not recommended but technically possible.
Looks good to me. |
44f430a
to
7610d38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
One more thing: this change breaks the unit tests. You can run the tests by invoking Invoke-Pester .\Tests
. I suspect this happened because the tests are using FakeAzureModule as a fictional Azure module name, and the new logic ignores this module based on the name. Most likely, replacing FakeAzureModule with something like AzureRM.FakeModule in all the tests will fix the issue.
Ideally, it would also be great to add new tests verifying the Az vs. AzureRM logic, but I will not be insisting on that. However, we should not break the existing tests.
If I can give a suggestion, instead of doing: As an example of how to support both Az and AzureRM without changing the function names from AzureRM to Az.
An added bonus is that this will probably not break the existing tests |
@mortenlerudjordet I like the idea of using @ayoung012 I'm ok either way: feel free to use or not use |
However, this will probably not help with the current test break: as far as I understand, the tests are broken not because of using wrong cmdlets, but because of the new logic that intentioinially separates Az from AzureRM based on module names. |
@AnatoliB If you execute Disable-AzureRmAlias at the end will this help with the reuse problem? |
Sorry, I misunderstood you, I thought you were talking about Enable-AzureRmAlias. Yes, invoking Disable-AzureRmAlias at the end should resolve this issue. |
The migration guide
https://docs.microsoft.com/en-us/powershell/azure/migrate-from-azurerm-to-az
asks that you remove AzureRM before enabling aliases. Is there any
reasoning behind this? Does the alias functionality do anything to ensure
the AzureRM module is not loaded if it is left installed and a AzureRM call
is made?
…On Tue., 11 Jun. 2019, 4:10 am Anatoli Beliaev, ***@***.***> wrote:
@mortenlerudjordet <https://github.com/mortenlerudjordet>
If you execute Disable-AzureRmAlias at the end will this help with the
reuse problem?
I don't see how this would help: the problem is that this command will
bring the AzureRm aliases into the current PS runspace. Regardless of where
it is invoked, the result will be the runspace will have these aliases left
over. Now, this runspace may be used again for running any other job on
this Automation account, and these new jobs may be affected. As an
Automation user, you don't have direct control over runspace reuse.
But then again, I don't see any realistic and important scenario where the
presence of the aliases would actually create a big problem. As soon as Az
is loaded, the user is not supposed to use AzureRM cmdlets on this
Automation account anyway, so the fact that AzureRM cmdlets are hidden by
aliases should not actually hurt. And, if it does, they can always invoke
Disable-AzureRmAlias as a workaround. So, no big problem, just something
to be aware of.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6?email_source=notifications&email_token=ACWYTLJWKKMCNGVDQKE4MDTPZ2KJDA5CNFSM4HMMQHLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXKVWUI#issuecomment-500521809>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWYTLO36TX3F4BP464VNADPZ2KJDANCNFSM4HMMQHLA>
.
|
@ayoung012 I suspect the migration doc mentions removing AzureRM as a general good practice simply to make sure AzureRM modules are not loaded, not because there is any specific issue with enabling aliases. Unfortunately, we cannot completely remove AzureRM modules from Automation. You can check the cmdlet source code - it is open source - most likely it simply creates aliases, so it should not cause any problem. |
Only problem I had with the suggested use was that if you have a new AA account with the default AzureRM versions the import of AzureRM.profile, AzureRM.Automation and AzureRM.Resources will fail. One will need to update them to the latest version "manually" (or using code that does not have any dependencies to the Azure modules). Though this more a problem with how old the AzureRM version that comes with a new AA account are. The shared resources in use for executing runbooks needs to be updated with newer versions of AzureRM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @ayoung012!
If the parameter AzureModuleClass is set to 'Az', the runbook will attempt to update all modules only using Az modules itself. The script takes care not to use any conflicting modules from AzureRM.
Default behavior is the same: to use AzureRM modules throughout.
issue #5
Note: if for some reason you have installed both AzureRM and Az modules in your automation account, this script will still attempt to update all of them. It is perhaps desirable to present the user with a warning instead...