Open dolauli opened 1 year ago
Removing -DefaultProfile should not be the solution. Of the 2 workarounds offered:
Multi-subscription and multi-tenant management at scale is becoming more common among the largest Azure customers, and removing -DefaultProfile will effectively eliminate Az cmdlets as a potential option in these types of infrastructures.
I agree with @kwill-MSFT , removing the "defaultProfile" or AzContext as a parameter is NOT a solution. We run our code in azure functions, and we need to be able to pass the right context as a parameter for functions that fan-out and do work. With recent changes to the Azure Policy and the use of autorest , our code broke, not because of the new "output" from some cmdlets which was expected/announced but rather because some cmdlets like Get-AzPolicyAssignment no longer support the DefaultProfile/AzContext parameter (it's useless/ignored).
In the past, where we ran into issues with set-azcontext for multi-tenant environments and azure functions, Microsoft explicitly asked us to always pass the context to each az cmdlet , so please take into consideration this and bring this back as this is the only reliable way of handling multi-tenant environments where is imperative we ensure we perform the action with the right context when running code in azure functions.
Description
Cmdlets are generated by autorest.powershell provides the parameter
-DefaultProfile
, which actually are not functional actually. And below are some workarounds.set-azcontext
to switch the context instead of using-DefaultProfile
.-SubscriptionId
parameters, which are supported by those autogen cmdlets.Steps that will be taken considering removing those un-functional
-DefaultProfile
are breaking changes even if they are not functional-DefaultProfile
is used to tell users the parameter is not functional and will be removed-DefaultProfile
-DefaultProfile
is supported by the generator autorest.powershell.Link to the feature request in autorest.powershell.
Issue script & Debug output
Environment data
Module versions
Error output