diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml index 70920b8595b8..44135e3a1a8e 100644 --- a/.github/policies/resourceManagement.yml +++ b/.github/policies/resourceManagement.yml @@ -1717,6 +1717,22 @@ configuration: - hiaga replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}. assignMentionees: False + - if: + - or: + - labelAdded: + label: Service Attention + - labelAdded: + label: DesktopVirtualization + - hasLabel: + label: Service Attention + - hasLabel: + label: DesktopVirtualization + then: + - mentionUsers: + mentionees: + - alec-baird,costinhagiu + replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}. + assignMentionees: False - if: - or: - labelAdded: @@ -2049,6 +2065,9 @@ configuration: then: - mentionUsers: mentionees: + - bavneetsingh16 + - Arif-lakhani + - ramyasreechakka - NarayanThiru replyTemplate: Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}. assignMentionees: False diff --git a/src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs b/src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs index 1a5a3536873d..4492ca84f1ff 100644 --- a/src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs +++ b/src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs @@ -45,6 +45,7 @@ using Microsoft.WindowsAzure.Commands.Utilities.Common; using Microsoft.Azure.PowerShell.Common.Share.Survey; using Microsoft.Azure.Commands.Profile.Utilities; +using System.Management.Automation.Runspaces; namespace Microsoft.Azure.Commands.Profile { @@ -249,6 +250,7 @@ protected override IAzureContext DefaultContext protected override void BeginProcessing() { base.BeginProcessing(); + ValidateActionRequiredMessageCanBePresented(); if (AzureEnvironment.PublicEnvironments.ContainsKey(EnvironmentName.AzureCloud)) { _environment = AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud]; @@ -273,11 +275,19 @@ protected override void BeginProcessing() _writeWarningEvent -= WriteWarningSender; _writeWarningEvent += WriteWarningSender; + _writeInformationEvent -= WriteInformationSender; + _writeInformationEvent += WriteInformationSender; + // store the original write warning handler, register a thread safe one AzureSession.Instance.TryGetComponent(WriteWarningKey, out _originalWriteWarning); AzureSession.Instance.UnregisterComponent>(WriteWarningKey); AzureSession.Instance.RegisterComponent(WriteWarningKey, () => _writeWarningEvent); + // store the original write information handler, register a thread safe one + AzureSession.Instance.TryGetComponent(WriteInformationKey, out _originalWriteInformation); + AzureSession.Instance.UnregisterComponent>(WriteInformationKey); + AzureSession.Instance.RegisterComponent(WriteInformationKey, () => _writeInformationEvent); + // todo: ideally cancellation token should be passed to authentication factory as a parameter // however AuthenticationFactory.Authenticate does not support it // so I store it in AzureSession.Instance as a global variable @@ -289,11 +299,19 @@ protected override void BeginProcessing() private event EventHandler _writeWarningEvent; private event EventHandler _originalWriteWarning; + private event EventHandler _writeInformationEvent; + private event EventHandler _originalWriteInformation; + private void WriteWarningSender(object sender, StreamEventArgs args) { _tasks.Enqueue(new Task(() => this.WriteWarning(args.Message))); } + private void WriteInformationSender(object sender, StreamEventArgs args) + { + _tasks.Enqueue(new Task(() => this.WriteInformation(args.Message))); + } + protected override void StopProcessing() { if (AzureSession.Instance.TryGetComponent("LoginCancellationToken", out CancellationTokenSource cancellationTokenSource)) @@ -562,6 +580,20 @@ public override void ExecuteCmdlet() } } + private void ValidateActionRequiredMessageCanBePresented() + { + if (UseDeviceAuthentication.IsPresent && IsWriteInformationIgnored()) + { + throw new ActionPreferenceStopException(Resources.DoNotIgnoreInformationIfUserDeviceAuth); + } + } + + private bool IsWriteInformationIgnored() + { + return !MyInvocation.BoundParameters.ContainsKey("InformationAction") && ActionPreference.Ignore.ToString().Equals(SessionState?.PSVariable?.GetValue("InformationPreference", ActionPreference.SilentlyContinue)?.ToString() ?? "") || + MyInvocation.BoundParameters.TryGetValue("InformationAction", out var value) && ActionPreference.Ignore.ToString().Equals(value?.ToString() ?? "", StringComparison.InvariantCultureIgnoreCase); + } + private string PreProcessAuthScope() { string mappedScope = AuthScope; @@ -774,6 +806,9 @@ protected override void EndProcessing() // unregister the thread-safe write warning, because it won't work out of this cmdlet AzureSession.Instance.UnregisterComponent>(WriteWarningKey); AzureSession.Instance.RegisterComponent(WriteWarningKey, () => _originalWriteWarning); + // unregister the thread-safe write information, because it won't work out of this cmdlet + AzureSession.Instance.UnregisterComponent>(WriteInformationKey); + AzureSession.Instance.RegisterComponent(WriteInformationKey, () => _originalWriteInformation); } } } diff --git a/src/Accounts/Accounts/ChangeLog.md b/src/Accounts/Accounts/ChangeLog.md index ac7077abd901..19a575e111eb 100644 --- a/src/Accounts/Accounts/ChangeLog.md +++ b/src/Accounts/Accounts/ChangeLog.md @@ -19,6 +19,7 @@ --> ## Upcoming Release +* Redirected device code login messages from warning stream to information stream if use device authentication in `Connect-AzAccount`. ## Version 2.15.1 * Upgraded the reference of Azure PowerShell Common to 1.3.90-preview. @@ -26,7 +27,9 @@ - Renamed token cache from `msal.cache` to `msal.cache.cae` or `masl.cache.nocae`. * Enabled Continue Access Evaluation (CAE) for all Service Principals login methods. * Supported signing in with Microsoft Account (MSA) via Web Account Manager (WAM). Enable it by `Set-AzConfig -EnableLoginByWam $true`. -* Adjusted output format to be more user-friendly for `Get-AzContext/Tenant/Subscription` and `Invoke-AzRestMethod`. +* Adjusted output format to be more user-friendly for `Get-AzContext/Tenant/Subscription` and `Invoke-AzRestMethod`, including + - ordering and grouping output items to make items easy to find. + - re-prioritizing positions for output properties to highlight valuable properties. * Fixed the multiple `x-ms-unique-id` values issue. ## Version 2.15.0 diff --git a/src/Accounts/Accounts/Properties/Resources.Designer.cs b/src/Accounts/Accounts/Properties/Resources.Designer.cs index 2298c200f30a..1e31ef0f240a 100644 --- a/src/Accounts/Accounts/Properties/Resources.Designer.cs +++ b/src/Accounts/Accounts/Properties/Resources.Designer.cs @@ -537,6 +537,15 @@ internal static string DisableDataCollection { } } + /// + /// Looks up a localized string similar to Please do not set InformationAction or $InformationPreference to Ignore if you want to use device code authentication.. + /// + internal static string DoNotIgnoreInformationIfUserDeviceAuth { + get { + return ResourceManager.GetString("DoNotIgnoreInformationIfUserDeviceAuth", resourceCulture); + } + } + /// /// Looks up a localized string similar to Allow Azure PowerShell cmdlets to send data to Microsoft to improve the customer experience. /// diff --git a/src/Accounts/Accounts/Properties/Resources.resx b/src/Accounts/Accounts/Properties/Resources.resx index a8b3f3f8e0cd..f3d5dceb694b 100644 --- a/src/Accounts/Accounts/Properties/Resources.resx +++ b/src/Accounts/Accounts/Properties/Resources.resx @@ -595,4 +595,7 @@ Personally identifiable information and confidential data may be written to the file located at '{0}'. Please ensure that appropriate access controls are assigned to the saved file. + + Please do not set InformationAction or $InformationPreference to Ignore if you want to use device code authentication. + \ No newline at end of file diff --git a/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs b/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs index e615e4758df2..4bba654f0262 100644 --- a/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs +++ b/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs @@ -12,10 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; -using System.Threading; -using System.Threading.Tasks; - using Azure.Core; using Azure.Identity; @@ -24,6 +20,12 @@ using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; using Microsoft.Azure.Commands.ResourceManager.Common; +using Microsoft.WindowsAzure.Commands.Common; + +using System; +using System.Text; +using System.Threading; +using System.Threading.Tasks; namespace Microsoft.Azure.PowerShell.Authenticators { @@ -64,7 +66,7 @@ public override Task Authenticate(AuthenticationParameters paramet private Task DeviceCodeFunc(DeviceCodeInfo info, CancellationToken cancellation) { - WriteWarning(info.Message); + WriteInfomartion(info.Message, info.UserCode); return Task.CompletedTask; } @@ -73,12 +75,29 @@ public override bool CanAuthenticate(AuthenticationParameters parameters) return (parameters as DeviceCodeParameters) != null; } - private void WriteWarning(string message) + + private void WriteInfomartion(string message, string userCode) { - EventHandler writeWarningEvent; - if (AzureSession.Instance.TryGetComponent(AzureRMCmdlet.WriteWarningKey, out writeWarningEvent)) + + var loginInfo = new StringBuilder(); + string LoginToAzurePhrase = $"{PSStyle.Bold}{PSStyle.BackgroundColor.Blue}[Login to Azure]{PSStyle.Reset} "; + loginInfo.Append(LoginToAzurePhrase); + + if (!string.IsNullOrEmpty(userCode)) + { + var formattedUserCode = $"{PSStyle.Underline}{userCode}{PSStyle.Reset}"; + var formattedMessage = message.Replace(userCode, formattedUserCode); + loginInfo.Append(formattedMessage); + } + else + { + loginInfo.Append(message); + } + + EventHandler writeInforamtionEvent; + if (AzureSession.Instance.TryGetComponent(AzureRMCmdlet.WriteInformationKey, out writeInforamtionEvent)) { - writeWarningEvent(this, new StreamEventArgs() { Message = message }); + writeInforamtionEvent(this, new StreamEventArgs() { Message = loginInfo.ToString() }); } } } diff --git a/src/Resources/ResourceManager/Implementation/ResourceGroupDeployments/NewAzureResourceGroupDeploymentCmdlet.cs b/src/Resources/ResourceManager/Implementation/ResourceGroupDeployments/NewAzureResourceGroupDeploymentCmdlet.cs index 6c0ff02529f4..55ff4f9b4377 100644 --- a/src/Resources/ResourceManager/Implementation/ResourceGroupDeployments/NewAzureResourceGroupDeploymentCmdlet.cs +++ b/src/Resources/ResourceManager/Implementation/ResourceGroupDeployments/NewAzureResourceGroupDeploymentCmdlet.cs @@ -78,6 +78,9 @@ public class NewAzureResourceGroupDeploymentCmdlet : DeploymentCreateCmdlet [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } + [Parameter(Mandatory = false, HelpMessage = "Aux tenant ids for cross tenant references in deployments.")] + public string[] AuxTenant { get; set; } + protected override ConfirmImpact ConfirmImpact => ((CmdletAttribute)Attribute.GetCustomAttribute( typeof(NewAzureResourceGroupDeploymentCmdlet), typeof(CmdletAttribute))).ConfirmImpact; @@ -102,7 +105,8 @@ public class NewAzureResourceGroupDeploymentCmdlet : DeploymentCreateCmdlet Type = RollbackToLastDeployment ? OnErrorDeploymentType.LastSuccessful : OnErrorDeploymentType.SpecificDeployment, DeploymentName = RollbackToLastDeployment ? null : RollBackDeploymentName } - : null + : null, + AuxTenantHeaders = GetAuxiliaryAuthHeaderFromTenantIds(AuxTenant) }; protected override PSDeploymentWhatIfCmdletParameters BuildWhatIfParameters() => new PSDeploymentWhatIfCmdletParameters( @@ -117,7 +121,7 @@ public class NewAzureResourceGroupDeploymentCmdlet : DeploymentCreateCmdlet templateParametersUri: this.TemplateParameterUri, templateParametersObject: this.GetTemplateParameterObject(), resultFormat: this.WhatIfResultFormat, - excludeChangeTypes: this.WhatIfExcludeChangeType); + excludeChangeTypes: this.WhatIfExcludeChangeType); protected override void OnProcessRecord() { diff --git a/src/Resources/ResourceManager/SdkClient/NewResourceManagerSdkClient.cs b/src/Resources/ResourceManager/SdkClient/NewResourceManagerSdkClient.cs index e22e595ad97a..aa1329cc71ae 100644 --- a/src/Resources/ResourceManager/SdkClient/NewResourceManagerSdkClient.cs +++ b/src/Resources/ResourceManager/SdkClient/NewResourceManagerSdkClient.cs @@ -511,7 +511,15 @@ private DeploymentValidateResult ValidateDeployment(PSDeploymentCmdletParameters return ResourceManagementClient.Deployments.ValidateAtManagementGroupScope(parameters.ManagementGroupId, parameters.DeploymentName, scopedDeployment); case DeploymentScopeType.ResourceGroup: - return ResourceManagementClient.Deployments.Validate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); + if (parameters.AuxTenantHeaders != null) + { + return ResourceManagementClient.Deployments.ValidateWithHttpMessagesAsync(parameters.ResourceGroupName, parameters.DeploymentName, deployment, + customHeaders: ConvertAuxTenantDictionary(parameters.AuxTenantHeaders)).GetAwaiter().GetResult().Body; + } + else + { + return ResourceManagementClient.Deployments.Validate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); + } case DeploymentScopeType.Subscription: default: @@ -647,7 +655,15 @@ private void BeginDeployment(PSDeploymentCmdletParameters parameters, Deployment break; case DeploymentScopeType.ResourceGroup: - ResourceManagementClient.Deployments.BeginCreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); + if (parameters.AuxTenantHeaders != null) + { + ResourceManagementClient.Deployments.BeginCreateOrUpdateWithHttpMessagesAsync(parameters.ResourceGroupName, parameters.DeploymentName, deployment, + customHeaders: ConvertAuxTenantDictionary(parameters.AuxTenantHeaders)).GetAwaiter().GetResult(); + } + else + { + ResourceManagementClient.Deployments.BeginCreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); + } break; case DeploymentScopeType.Subscription: @@ -656,6 +672,22 @@ private void BeginDeployment(PSDeploymentCmdletParameters parameters, Deployment break; } } + /// + /// Conversion method for aux tenant dictionary to put it in correct format for passing as custom header object in sdk. + /// + /// Dictionary of tenant to tokens. + private Dictionary> ConvertAuxTenantDictionary(IDictionary> auxTenants) + { + if (auxTenants == null) return null; + + var headers = new Dictionary> (); + foreach (KeyValuePair> entry in auxTenants) + { + headers[entry.Key] = entry.Value.ToList(); + } + + return headers; + } private void RunDeploymentValidation(PSDeploymentCmdletParameters parameters, Deployment deployment) { diff --git a/src/Resources/ResourceManager/SdkModels/Deployments/PSDeploymentCmdletParameters.cs b/src/Resources/ResourceManager/SdkModels/Deployments/PSDeploymentCmdletParameters.cs index 9029c67cdde5..7a1ecbce0cae 100644 --- a/src/Resources/ResourceManager/SdkModels/Deployments/PSDeploymentCmdletParameters.cs +++ b/src/Resources/ResourceManager/SdkModels/Deployments/PSDeploymentCmdletParameters.cs @@ -41,5 +41,7 @@ public class PSDeploymentCmdletParameters public string DeploymentDebugLogLevel { get; set; } public OnErrorDeployment OnErrorDeployment { get; set; } + + public IDictionary> AuxTenantHeaders { get; set; } } } diff --git a/src/Resources/Resources/ChangeLog.md b/src/Resources/Resources/ChangeLog.md index d96c1d6df931..7de127ef3ecf 100644 --- a/src/Resources/Resources/ChangeLog.md +++ b/src/Resources/Resources/ChangeLog.md @@ -19,6 +19,7 @@ --> ## Upcoming Release +* Added `AuxTenant` parameter in `New-AzResourceGroupDeployment`to support cross-tenant deployment. ## Version 6.15.0 * Supported `-SkipClientSideScopeValidation` in RoleAssignment and RoleDefinition related commands. [#22473] diff --git a/src/Resources/Resources/help/New-AzResourceGroupDeployment.md b/src/Resources/Resources/help/New-AzResourceGroupDeployment.md index ef1250394a49..be4b8a287ff4 100644 --- a/src/Resources/Resources/help/New-AzResourceGroupDeployment.md +++ b/src/Resources/Resources/help/New-AzResourceGroupDeployment.md @@ -18,8 +18,9 @@ Adds an Azure deployment to a resource group. New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateFile [-SkipTemplateParameterPrompt] - [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateFile + [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] ``` ### ByTemplateObjectAndParameterObject @@ -27,9 +28,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterObject - -TemplateObject [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] + -TemplateParameterObject -TemplateObject [-SkipTemplateParameterPrompt] [-Pre] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByTemplateFileAndParameterObject @@ -37,9 +38,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterObject - -TemplateFile [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] + -TemplateParameterObject -TemplateFile [-SkipTemplateParameterPrompt] [-Pre] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByTemplateUriAndParameterObject @@ -47,9 +48,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterObject - -TemplateUri [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] + -TemplateParameterObject -TemplateUri [-SkipTemplateParameterPrompt] [-Pre] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByTemplateSpecResourceIdAndParamsObject @@ -57,9 +58,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterObject - -TemplateSpecId [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] + -TemplateParameterObject -TemplateSpecId [-SkipTemplateParameterPrompt] [-Pre] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByTemplateObjectAndParameterFile @@ -67,7 +68,7 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterFile + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterFile -TemplateObject [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -77,9 +78,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterFile -TemplateFile - [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterFile + -TemplateFile [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] + [-WhatIf] [-Confirm] [] ``` ### ByTemplateUriAndParameterFile @@ -87,9 +88,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterFile -TemplateUri - [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterFile + -TemplateUri [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] + [-WhatIf] [-Confirm] [] ``` ### ByTemplateSpecResourceIdAndParams @@ -97,9 +98,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterFile -TemplateSpecId - [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterFile + -TemplateSpecId [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] + [-WhatIf] [-Confirm] [] ``` ### ByParameterFileWithNoTemplate @@ -107,7 +108,7 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterFile + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterFile [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -117,7 +118,7 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterUri + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterUri -TemplateObject [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -127,9 +128,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterUri -TemplateFile - [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterUri + -TemplateFile [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] + [-WhatIf] [-Confirm] [] ``` ### ByTemplateUriAndParameterUri @@ -137,9 +138,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterUri -TemplateUri - [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterUri + -TemplateUri [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] + [-WhatIf] [-Confirm] [] ``` ### ByTemplateSpecResourceIdAndParamsUri @@ -147,9 +148,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateParameterUri -TemplateSpecId - [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateParameterUri + -TemplateSpecId [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] + [-WhatIf] [-Confirm] [] ``` ### ByTemplateObjectWithNoParameters @@ -157,7 +158,7 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateObject + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateObject [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -167,8 +168,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateUri [-SkipTemplateParameterPrompt] - [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateUri + [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] ``` ### ByTemplateSpecResourceId @@ -176,8 +178,9 @@ New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mod New-AzResourceGroupDeployment [-Name ] -ResourceGroupName [-Mode ] [-DeploymentDebugLogLevel ] [-RollbackToLastDeployment] [-RollBackDeploymentName ] [-Tag ] [-WhatIfResultFormat ] [-WhatIfExcludeChangeType ] [-Force] - [-ProceedIfNoChange] [-AsJob] [-QueryString ] -TemplateSpecId [-SkipTemplateParameterPrompt] - [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-ProceedIfNoChange] [-AsJob] [-AuxTenant ] [-QueryString ] -TemplateSpecId + [-SkipTemplateParameterPrompt] [-Pre] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -264,6 +267,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -AuxTenant +Aux tenant ids for cross tenant deployments + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -DefaultProfile The credentials, account, tenant, and subscription used for communication with azure diff --git a/tools/DevTools/CommonRepo.psm1 b/tools/DevTools/CommonRepo.psm1 index 8c9888997981..4bde9a8b573b 100644 --- a/tools/DevTools/CommonRepo.psm1 +++ b/tools/DevTools/CommonRepo.psm1 @@ -36,16 +36,28 @@ function Connect-CommonRepo { if ($LASTEXITCODE -ne 0) { throw "Failed to add $csproj to Accounts.sln" } +<# + known common project references: + Authentication.csproj -> Authentication.Abstractions, ResourceManager + Accounts.csproj -> Authentication.Abstractions, ResourceManager, Common + Accounts.Test.csproj -> Authentication.Abstractions, ResourceManager, Common + TestFx.csproj -> Graph.Rbac.csproj + AssemblyLoading.csproj -> Common +#> + # add all common projects to Authentication.csproj because it will be referenced by most Az projects dotnet add ./Authentication/Authentication.csproj reference $csproj if ($LASTEXITCODE -ne 0) { throw "Failed to add $csproj to Authentication.csproj" } } + # AssemblyLoading.csproj references Common.csproj and does not reference Autehtication.csproj dotnet add ./AssemblyLoading/AssemblyLoading.csproj reference "$CommonRepoPath/src/Common/Common.csproj" if ($LASTEXITCODE -ne 0) { throw "Failed to add Common.csproj to AssemblyLoading.csproj" } + + # add common project references below for csproj which does not reference Authentication.csproj } finally { Pop-Location @@ -81,7 +93,6 @@ function Connect-CommonRepo { function Disconnect-CommonRepo { Write-Host "Please run the following commands to undo Connect-CommonRepo. Double check those files do not have wanted changes. git checkout -- ./src/Accounts/Accounts.sln - git checkout -- ./src/Accounts/Accounts/Accounts.csproj git checkout -- ./src/Accounts/AssemblyLoading/AssemblyLoading.csproj git checkout -- ./src/Accounts/Authentication/Authentication.csproj git checkout -- ./tools/Common.Netcore.Dependencies.targets