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 21910100d4c1..1b21b3cb166b 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.
* Supported `-SkipClientSideScopeValidation` in RoleAssignment and RoleDefinition related commands. [#22473]
* Updated Bicep build logic to use --stdout flag instead of creating a temporary file on disk.
* Fixed exception when `-ApiVersion` is specified for `Get-AzResource`, affected by some resource types.
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