diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index db5ed26718ea..a6cd002498ef 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -57,10 +57,19 @@ This may take some time... $DefaultPSRepository = "PSGallery" } - Install-Module AzureRM -Repository $DefaultPSRepository - Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + $_InstallationPolicy = (Get-PSRepository -Name $DefaultPSRepository).InstallationPolicy + try + { + Set-PSRepository -Name $DefaultPSRepository -InstallationPolicy Trusted + + Install-Module AzureRM -Repository $DefaultPSRepository + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." - Update-AzureRM -Repository $DefaultPSRepository + Update-AzureRM -Repository $DefaultPSRepository + } finally { + # Clean up + Set-PSRepository -Name $DefaultPSRepository -InstallationPolicy $_InstallationPolicy + } } elseif ($Uninstall.IsPresent) { @@ -72,6 +81,7 @@ This may take some time... $env:PSModulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules;$env:ProgramFiles\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules\" Uninstall-AzureRM + Uninstall-Module -Name AzureRM -Confirm:$false -Force } else { diff --git a/src/Common/Commands.Common/AzureRmProfileProvider.cs b/src/Common/Commands.Common/AzureRmProfileProvider.cs index 16aae9bc4e24..fddf65d662a4 100644 --- a/src/Common/Commands.Common/AzureRmProfileProvider.cs +++ b/src/Common/Commands.Common/AzureRmProfileProvider.cs @@ -12,6 +12,7 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Microsoft.Azure.Common.Authentication; using Microsoft.Azure.Common.Authentication.Models; namespace Microsoft.WindowsAzure.Commands.Common diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs index cfdd74df9587..534e719037ac 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs @@ -37,10 +37,10 @@ public abstract class AzureRMCmdlet : AzurePSCmdlet /// static AzureRMCmdlet() { - if (AzureSession.DataStore == null) + if (!TestMockSupport.RunningMocked) { AzureSession.DataStore = new DiskDataStore(); - } + } } public AzureRMCmdlet() diff --git a/src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ExpressRouteCircuitTests.ps1 b/src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ExpressRouteCircuitTests.ps1 index 6da2a198c1a2..97db60379a6a 100644 --- a/src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ExpressRouteCircuitTests.ps1 +++ b/src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ExpressRouteCircuitTests.ps1 @@ -31,7 +31,7 @@ function Test-ExpressRouteCircuitCRUD $resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation # Create the ExpressRouteCircuit - $circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuName "standard_meteredData" -SkuTier Standard -SkuFamily MeteredData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000; + $circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuTier Standard -SkuFamily MeteredData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000; # get Circuit $getCircuit = Get-AzureRmExpressRouteCircuit -Name $circuitName -ResourceGroupName $rgname @@ -42,7 +42,7 @@ function Test-ExpressRouteCircuitCRUD Assert-NotNull $getCircuit.Location Assert-NotNull $getCircuit.Etag Assert-AreEqual 0 @($getCircuit.Peerings).Count - Assert-AreEqual "standard_meteredData" $getCircuit.Sku.Name + Assert-AreEqual "Standard_MeteredData" $getCircuit.Sku.Name Assert-AreEqual "Standard" $getCircuit.Sku.Tier Assert-AreEqual "MeteredData" $getCircuit.Sku.Family Assert-AreEqual "equinix" $getCircuit.ServiceProviderProperties.ServiceProviderName @@ -108,7 +108,7 @@ function Test-ExpressRouteCircuitPeeringCRUD # Create the ExpressRouteCircuit with peering $peering = New-AzureRmExpressRouteCircuitPeeringConfig -Name AzurePrivatePeering -PeeringType AzurePrivatePeering -PeerASN 100 -PrimaryPeerAddressPrefix "192.168.1.0/30" -SecondaryPeerAddressPrefix "192.168.2.0/30" -VlanId 200 - $circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuName "standard_meteredData" -SkuTier Standard -SkuFamily MeteredData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000 -Peering $peering + $circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuTier Standard -SkuFamily MeteredData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000 -Peering $peering #verification Assert-AreEqual $rgName $circuit.ResourceGroupName @@ -116,7 +116,7 @@ function Test-ExpressRouteCircuitPeeringCRUD Assert-NotNull $circuit.Location Assert-NotNull $circuit.Etag Assert-AreEqual 1 @($circuit.Peerings).Count - Assert-AreEqual "standard_meteredData" $circuit.Sku.Name + Assert-AreEqual "Standard_MeteredData" $circuit.Sku.Name Assert-AreEqual "Standard" $circuit.Sku.Tier Assert-AreEqual "MeteredData" $circuit.Sku.Family Assert-AreEqual "equinix" $circuit.ServiceProviderProperties.ServiceProviderName diff --git a/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/NewAzureExpressRouteCircuitCommand.cs b/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/NewAzureExpressRouteCircuitCommand.cs index bafd30d633eb..cea0e011cef8 100644 --- a/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/NewAzureExpressRouteCircuitCommand.cs +++ b/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/NewAzureExpressRouteCircuitCommand.cs @@ -50,11 +50,6 @@ public class NewAzureExpressRouteCircuitCommand : ExpressRouteCircuitBaseCmdlet [ValidateNotNullOrEmpty] public virtual string Location { get; set; } - [Parameter( - Mandatory = false, - ValueFromPipelineByPropertyName = true)] - public string SkuName { get; set; } - [Parameter( Mandatory = false, ValueFromPipelineByPropertyName = true)] @@ -136,12 +131,12 @@ private PSExpressRouteCircuit CreateExpressRouteCircuit() circuit.Location = this.Location; // Construct sku - if (!string.IsNullOrEmpty(this.SkuName)) + if (!string.IsNullOrEmpty(this.SkuTier)) { circuit.Sku = new PSExpressRouteCircuitSku(); - circuit.Sku.Name = this.SkuName; circuit.Sku.Tier = this.SkuTier; circuit.Sku.Family = this.SkuFamily; + circuit.Sku.Name = this.SkuTier + "_" + this.SkuFamily; } // construct the service provider properties diff --git a/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/SetAzureExpressRouteCircuitCommand.cs b/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/SetAzureExpressRouteCircuitCommand.cs index b3801cc7d9ef..bedbf3026d46 100644 --- a/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/SetAzureExpressRouteCircuitCommand.cs +++ b/src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/SetAzureExpressRouteCircuitCommand.cs @@ -41,12 +41,12 @@ protected override void ProcessRecord() } // Map to the sdk object - var vnetModel = Mapper.Map(this.ExpressRouteCircuit); - vnetModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.ExpressRouteCircuitType; - vnetModel.Tags = TagsConversionHelper.CreateTagDictionary(this.ExpressRouteCircuit.Tag, validate: true); + var erModel = Mapper.Map(this.ExpressRouteCircuit); + erModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.ExpressRouteCircuitType; + erModel.Tags = TagsConversionHelper.CreateTagDictionary(this.ExpressRouteCircuit.Tag, validate: true); // Execute the Create ExpressRouteCircuit call - this.ExpressRouteCircuitClient.CreateOrUpdate(this.ExpressRouteCircuit.ResourceGroupName, this.ExpressRouteCircuit.Name, vnetModel); + this.ExpressRouteCircuitClient.CreateOrUpdate(this.ExpressRouteCircuit.ResourceGroupName, this.ExpressRouteCircuit.Name, erModel); var getExpressRouteCircuit = this.GetExpressRouteCircuit(this.ExpressRouteCircuit.ResourceGroupName, this.ExpressRouteCircuit.Name); WriteObject(getExpressRouteCircuit); diff --git a/src/ResourceManager/Profile/AzureRM.Profile.psd1 b/src/ResourceManager/Profile/AzureRM.Profile.psd1 index a417f7151faa..737e51ce6071 100644 --- a/src/ResourceManager/Profile/AzureRM.Profile.psd1 +++ b/src/ResourceManager/Profile/AzureRM.Profile.psd1 @@ -51,7 +51,7 @@ RequiredModules = @() RequiredAssemblies = @() # Script files (.ps1) that are run in the caller's environment prior to importing this module -ScriptsToProcess = @() +ScriptsToProcess = @('CheckVersions.ps1') # Type files (.ps1xml) to be loaded when importing this module TypesToProcess = @() diff --git a/src/ResourceManager/Profile/CheckVersions.ps1 b/src/ResourceManager/Profile/CheckVersions.ps1 new file mode 100644 index 000000000000..5c2f18e6890a --- /dev/null +++ b/src/ResourceManager/Profile/CheckVersions.ps1 @@ -0,0 +1,63 @@ +$AzureRMModules = @( + "AzureRM.ApiManagement"; + "AzureRM.Automation"; + "AzureRM.Backup"; + "AzureRM.Batch"; + "AzureRM.Compute"; + "AzureRM.DataFactories"; + "AzureRM.Dns"; + "AzureRM.HDInsight"; + "AzureRM.Insights"; + "AzureRM.KeyVault"; + "AzureRM.Network"; + "AzureRM.OperationalInsights"; + "AzureRM.RedisCache"; + "AzureRM.Resources"; + "AzureRM.SiteRecovery"; + "AzureRM.Sql"; + "AzureRM.Storage"; + "AzureRM.StreamAnalytics"; + "AzureRM.Tags"; + "AzureRM.TrafficManager"; + "AzureRM.UsageAggregates"; + "AzureRM.Websites" +) + +$global:AvailableModules = @() + +function CheckVersions { + $profile = GetModuleInfo("AzureRM.Profile") + if (-not $profile) + { + exit 0 + } + ForEach ($moduleName in $AzureRMModules) { + $module = GetModuleInfo($moduleName) + if ($module) + { + $module.RequiredModules | Where-Object {$_.Name -eq "AzureRM.Profile"} | ForEach { + if ($profile.Version.Major -ne $_.Version.Major) { + Write-Warning("$moduleName $($module.Version) is not compatible with $profile $($profile.Version)!") + } + } + } + } +} + +function GetModuleInfo { + param( + [Parameter(Position=0)] + [string] + $ModuleName) + + if ($global:AvailableModules.Length -eq 0) + { + $global:AvailableModules = Get-Module -ListAvailable + } + + return $global:AvailableModules ` + | Where-Object { $_.Name -eq $ModuleName} ` + | Select-Object -first 1 +} + +CheckVersions diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj index 7aba07db4bf8..255243591b76 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj +++ b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj @@ -181,6 +181,7 @@ + @@ -196,6 +197,15 @@ + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -205,6 +215,9 @@ PreserveNewest + + PreserveNewest + @@ -227,4 +240,4 @@ - \ No newline at end of file + diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg new file mode 100644 index 000000000000..82c6f31f5149 Binary files /dev/null and b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.ApiManagement.998.9.8.nupkg differ diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg new file mode 100644 index 000000000000..216dc5ae07a0 Binary files /dev/null and b/src/ResourceManager/Profile/Commands.Profile.Test/FakeModuleRepo/AzureRM.Profile.999.9.8.nupkg differ diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Entities/Resources/ResourceObjectFormat.cs b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.cs similarity index 62% rename from src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Entities/Resources/ResourceObjectFormat.cs rename to src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.cs index 6666e2b4c5b1..dd3202eb7114 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Entities/Resources/ResourceObjectFormat.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.cs @@ -12,21 +12,19 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources +using Microsoft.Azure.Commands.Resources.Test.ScenarioTests; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Xunit; + +namespace Microsoft.Azure.Commands.Profile.Test { - /// - /// The resource object format - /// - public enum ResourceObjectFormat + public class ProfileModuleTests { - /// - /// The legacy format. - /// - Legacy = 0, - - /// - /// The new format. - /// - New = 1 + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void WarningOnIncompatibleVersions() + { + ProfileController.NewInstance.RunPsTest("db1ab6f0-4769-4b27-930e-01e2ef9c123c", "Test-LoadProfileModule"); + } } } diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 new file mode 100644 index 000000000000..38f7b902e4a0 --- /dev/null +++ b/src/ResourceManager/Profile/Commands.Profile.Test/ProfileModuleTests.ps1 @@ -0,0 +1,43 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.SYNOPSIS +Tests warning gets printed on incompatible modules with profile +#> +function Test-LoadProfileModule +{ + # Push current profile module + Get-PackageProvider -Name NuGet -ForceBootstrap + $global:pushedProfileModule = $(Get-Module AzureRM.Profile).Path + Remove-Module AzureRM.Profile + try { + Register-PSRepository -Name "ProfileModuleTest" -SourceLocation (Resolve-Path .\FakeModuleRepo).Path -InstallationPolicy Trusted + try { + Install-Module AzureRM.ApiManagement -Scope CurrentUser -Repository ProfileModuleTest -RequiredVersion 998.9.8 + $global:buffer = Import-Module $global:pushedProfileModule 2>&1 3>&1 | Out-String + Write-Warning $global:buffer + Assert-True { $global:buffer -Like "*AzureRM.ApiManagement 998.9.8 is not compatible with AzureRM.Profile*" } + } catch [system.exception] { + Write-Error $_ -ErrorAction Continue + } finally { + Uninstall-Module AzureRM.ApiManagement -ErrorAction Ignore + Uninstall-Module AzureRM.Profile -ErrorAction Ignore + } + } catch [system.exception] { + Write-Error $_ -ErrorAction Continue + } finally { + Unregister-PSRepository -Name "ProfileModuleTest" + } +} \ No newline at end of file diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ProfileModuleTests/WarningOnIncompatibleVersions.json b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ProfileModuleTests/WarningOnIncompatibleVersions.json new file mode 100644 index 000000000000..f085c51a6519 --- /dev/null +++ b/src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.ProfileModuleTests/WarningOnIncompatibleVersions.json @@ -0,0 +1,5 @@ +{ + "Entries": [], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs b/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs index 801ba1080d6c..4f9a53d31fe5 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs @@ -55,11 +55,15 @@ public class AddAzureRMAccountCommand : AzureRMCmdlet , IModuleAssemblyInitializ [ValidateNotNullOrEmpty] public string AccessToken { get; set; } - [Parameter(Mandatory = false, HelpMessage = "Subscription")] + [Parameter(ParameterSetName = "AccessToken", Mandatory = true, HelpMessage = "Account Id for access token")] + [ValidateNotNullOrEmpty] + public string AccountId { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Subscription Id")] [ValidateNotNullOrEmpty] public string SubscriptionId { get; set; } - [Parameter(Mandatory = false, HelpMessage = "Subscription")] + [Parameter(Mandatory = false, HelpMessage = "Subscription name")] [ValidateNotNullOrEmpty] public string SubscriptionName { get; set; } @@ -97,7 +101,14 @@ protected override void ProcessRecord() if (!string.IsNullOrEmpty(AccessToken)) { + if (string.IsNullOrWhiteSpace(AccountId) ) + { + throw new PSInvalidOperationException(Resources.AccountIdRequired); + } + azureAccount.Type = AzureAccount.AccountType.AccessToken; + azureAccount.Id = AccountId; + azureAccount.SetProperty(AzureAccount.Property.AccessToken, AccessToken); } else if (ServicePrincipal.IsPresent) { @@ -127,7 +138,8 @@ protected override void ProcessRecord() var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.Profile); - WriteObject((PSAzureProfile)profileClient.Login(azureAccount, Environment, Tenant, SubscriptionId, SubscriptionName, password)); + WriteObject((PSAzureProfile)profileClient.Login(azureAccount, Environment, Tenant, SubscriptionId, + SubscriptionName, password)); } /// diff --git a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj index 0ed70994841b..c8444f45f9b2 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj +++ b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj @@ -146,6 +146,7 @@ + @@ -169,6 +170,10 @@ AzureRM.Profile.psd1 PreserveNewest + + CheckVersions.ps1 + PreserveNewest + PreserveNewest diff --git a/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureProfile.cs b/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureProfile.cs index 9c690a8a79f6..43e006617dac 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureProfile.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureProfile.cs @@ -34,7 +34,7 @@ public static implicit operator PSAzureProfile(AzureRMProfile profile) }; profile.Environments - .ForEach((e) => result.Environments.Add(e.Key, (PSAzureEnvironment)e.Value)); + .ForEach((e) => result.Environments[e.Key] = (PSAzureEnvironment)e.Value); return result; } @@ -54,8 +54,7 @@ public static implicit operator AzureRMProfile(PSAzureProfile profile) { Context = profile.Context }; - profile.Environments - .ForEach((e) => result.Environments.Add(e.Key, (AzureEnvironment)e.Value)); + profile.Environments.ForEach((e) => result.Environments[e.Key] = (AzureEnvironment) e.Value); return result; } diff --git a/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureRmAccount.cs b/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureRmAccount.cs index 8ac13163cf37..32159c3116e9 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureRmAccount.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Models/PSAzureRmAccount.cs @@ -36,11 +36,23 @@ public static implicit operator PSAzureRmAccount(AzureAccount account) return null; } - return new PSAzureRmAccount + var result = new PSAzureRmAccount { Id = account.Id, AccountType = account.Type.ToString() }; + + if (account.IsPropertySet(AzureAccount.Property.AccessToken)) + { + result.AccessToken = account.GetProperty(AzureAccount.Property.AccessToken); + } + + if (account.IsPropertySet(AzureAccount.Property.Tenants)) + { + result.Tenants = account.GetProperty(AzureAccount.Property.Tenants); + } + + return result; } /// @@ -65,6 +77,16 @@ public static implicit operator AzureAccount(PSAzureRmAccount account) result.Type = accountType; } + if (!string.IsNullOrWhiteSpace(account.AccessToken)) + { + result.SetProperty(AzureAccount.Property.AccessToken, account.AccessToken); + } + + if (!string.IsNullOrWhiteSpace(account.Tenants)) + { + result.SetProperty(AzureAccount.Property.Tenants, account.Tenants); + } + return result; } @@ -77,6 +99,16 @@ public static implicit operator AzureAccount(PSAzureRmAccount account) /// public string AccountType { get; set; } + /// + /// The tenant ids for the account + /// + public string Tenants { get; set; } + + /// + /// The access token for the account (if any) + /// + public string AccessToken { get; set; } + public override string ToString() { return this.Id; diff --git a/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs b/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs index 8d3697d3779c..3d553a1abcb0 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs @@ -25,6 +25,7 @@ using System.Linq; using System.Management.Automation; using System.Security; +using Microsoft.Azure.Commands.Profile.Models; namespace Microsoft.Azure.Commands.ResourceManager.Common { @@ -44,11 +45,13 @@ public RMProfileClient(AzureRMProfile profile) } } - public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment, string tenantId, string subscriptionId, string subscriptionName, SecureString password) + public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment, string tenantId, string subscriptionId, + string subscriptionName, SecureString password) { AzureSubscription newSubscription = null; AzureTenant newTenant = null; - ShowDialog promptBehavior = password == null ? ShowDialog.Always : ShowDialog.Never; + ShowDialog promptBehavior = (password == null && account.Type != AzureAccount.AccountType.AccessToken) + ? ShowDialog.Always : ShowDialog.Never; // (tenant and subscription are present) OR // (tenant is present and subscription is not provided) @@ -280,6 +283,12 @@ private IAccessToken AcquireAccessToken(AzureAccount account, SecureString password, ShowDialog promptBehavior) { + if (account.Type == AzureAccount.AccountType.AccessToken) + { + tenantId = tenantId ?? "Common"; + return new SimpleAccessToken(account, tenantId); + } + return AzureSession.AuthenticationFactory.Authenticate( account, environment, diff --git a/src/ResourceManager/Profile/Commands.Profile/Models/SimpleAccessToken.cs b/src/ResourceManager/Profile/Commands.Profile/Models/SimpleAccessToken.cs new file mode 100644 index 000000000000..6872c3c0b6f7 --- /dev/null +++ b/src/ResourceManager/Profile/Commands.Profile/Models/SimpleAccessToken.cs @@ -0,0 +1,90 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using Microsoft.Azure.Commands.Profile.Properties; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; + +namespace Microsoft.Azure.Commands.Profile.Models +{ + /// + /// Provides access token information for a bearer token + /// + public class SimpleAccessToken : IAccessToken + { + public const string _defaultTokenType = "Bearer"; + private string _tokenType; + + /// + /// Create a new access token from the given account and tenant id + /// + /// The account, containing user id, access token information + /// The tenant id for the given access token + /// The token type for the given token. + public SimpleAccessToken(AzureAccount account, string tenantId, string tokenType = _defaultTokenType) + { + if (account == null) + { + throw new ArgumentNullException("account"); + } + if (string.IsNullOrWhiteSpace(account.Id)) + { + throw new ArgumentOutOfRangeException("account", Resources.AccessTokenRequiresAccount); + } + if (account.Type != AzureAccount.AccountType.AccessToken || + !account.IsPropertySet(AzureAccount.Property.AccessToken)) + { + throw new ArgumentException(Resources.TypeNotAccessToken); + } + this.UserId = account.Id; + this._tokenType = tokenType; + this.AccessToken = account.GetProperty(AzureAccount.Property.AccessToken); + this.TenantId = tenantId; + } + + + /// + /// The access token to be applied to a request message + /// + public string AccessToken { get; private set; } + + /// + /// Authorize a request using an authorization setter function. + /// + /// The authorization token setter function. + public void AuthorizeRequest(System.Action authTokenSetter) + { + authTokenSetter(_tokenType, AccessToken); + } + + /// + /// The login type for this token + /// + public LoginType LoginType + { + get { return LoginType.OrgId; } + } + + /// + /// The tenant Id for this token. + /// + public string TenantId { get; private set; } + + /// + /// The User Id associated with this token. + /// + public string UserId { get; private set; } + } +} diff --git a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs index 4d0ead958c30..4a66c728e1aa 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs @@ -60,6 +60,24 @@ internal Resources() { } } + /// + /// Looks up a localized string similar to AccountId must be provided to use an AccessToken credential.. + /// + internal static string AccessTokenRequiresAccount { + get { + return ResourceManager.GetString("AccessTokenRequiresAccount", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Access token credentials must provide the AccountId parameter.. + /// + internal static string AccountIdRequired { + get { + return ResourceManager.GetString("AccountIdRequired", resourceCulture); + } + } + /// /// Looks up a localized string similar to Selected profile must not be null.. /// @@ -131,5 +149,14 @@ internal static string TenantAuthFailed { return ResourceManager.GetString("TenantAuthFailed", resourceCulture); } } + + /// + /// Looks up a localized string similar to To create an access token credential, you must provide an access token account.. + /// + internal static string TypeNotAccessToken { + get { + return ResourceManager.GetString("TypeNotAccessToken", resourceCulture); + } + } } } diff --git a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx index 0e92efc9cc35..9e39364a5eff 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx +++ b/src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + AccountId must be provided to use an AccessToken credential. + + + Access token credentials must provide the AccountId parameter. + Selected profile must not be null. @@ -141,4 +147,7 @@ Could not authenticate with tenant {0}. Please ensure that your account has access to this tenant and log in with Login-AzureRmAccount + + To create an access token credential, you must provide an access token account. + \ No newline at end of file diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Commands.Resources.Rest.csproj b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Commands.Resources.Rest.csproj index 04ce7ff14949..e0fe16144eb5 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Commands.Resources.Rest.csproj +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Commands.Resources.Rest.csproj @@ -120,7 +120,6 @@ - diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/JTokenExtensions.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/JTokenExtensions.cs index 6e6d7229ba17..133dbe03e07a 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/JTokenExtensions.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/JTokenExtensions.cs @@ -49,9 +49,8 @@ internal static class JTokenExtensions /// Converts a to a /// /// The - /// The /// The type of the object. - internal static PSObject ToPsObject(this JToken jtoken, ResourceObjectFormat objectFormat, string objectType = null) + internal static PSObject ToPsObject(this JToken jtoken, string objectType = null) { if (jtoken == null) { @@ -60,7 +59,7 @@ internal static PSObject ToPsObject(this JToken jtoken, ResourceObjectFormat obj if (jtoken.Type != JTokenType.Object) { - return new PSObject(JTokenExtensions.ConvertPropertyValueForPsObject(propertyValue: jtoken, objectFormat: objectFormat)); + return new PSObject(JTokenExtensions.ConvertPropertyValueForPsObject(propertyValue: jtoken)); } var jobject = (JObject)jtoken; @@ -75,7 +74,7 @@ internal static PSObject ToPsObject(this JToken jtoken, ResourceObjectFormat obj { psObject.Properties.Add(new PSNoteProperty( name: JTokenExtensions.ConvertToPascalCase(propertyName: property.Name), - value: JTokenExtensions.ConvertPropertyValueForPsObject(propertyValue: property.Value, objectFormat: objectFormat))); + value: JTokenExtensions.ConvertPropertyValueForPsObject(propertyValue: property.Value))); } return psObject; @@ -86,12 +85,11 @@ internal static PSObject ToPsObject(this JToken jtoken, ResourceObjectFormat obj /// used as the value of a . /// /// The value. - /// The - internal static object ConvertPropertyValueForPsObject(JToken propertyValue, ResourceObjectFormat objectFormat) + internal static object ConvertPropertyValueForPsObject(JToken propertyValue) { if (propertyValue.Type == JTokenType.Object) { - return propertyValue.ToPsObject(objectFormat); + return propertyValue.ToPsObject(); } if (propertyValue.Type == JTokenType.Array) @@ -102,7 +100,7 @@ internal static object ConvertPropertyValueForPsObject(JToken propertyValue, Res for (int i = 0; i < array.Length; ++i) { - array[i] = JTokenExtensions.ConvertPropertyValueForPsObject(jArray[i], objectFormat); + array[i] = JTokenExtensions.ConvertPropertyValueForPsObject(jArray[i]); } return array; diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/ResourceExtensions.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/ResourceExtensions.cs index 0c33817f4946..e8b9a7797aa1 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/ResourceExtensions.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/ResourceExtensions.cs @@ -32,8 +32,7 @@ internal static class ResourceExtensions /// Converts a object into a object. /// /// The object. - /// The - internal static PSObject ToPsObject(this Resource resource, ResourceObjectFormat objectFormat) + internal static PSObject ToPsObject(this Resource resource) { var resourceType = string.IsNullOrEmpty(resource.Id) ? null @@ -56,12 +55,12 @@ internal static PSObject ToPsObject(this Resource resource, ResourceObje { "Location", resource.Location }, { "SubscriptionId", string.IsNullOrEmpty(resource.Id) ? null : ResourceIdUtility.GetSubscriptionId(resource.Id) }, { "Tags", TagsHelper.GetTagsHashtables(resource.Tags) }, - { "Plan", resource.Plan.ToJToken().ToPsObject(objectFormat) }, - { "Properties", ResourceExtensions.GetProperties(resource, objectFormat) }, + { "Plan", resource.Plan.ToJToken().ToPsObject() }, + { "Properties", ResourceExtensions.GetProperties(resource) }, { "CreatedTime", resource.CreatedTime }, { "ChangedTime", resource.ChangedTime }, { "ETag", resource.ETag }, - { "Sku", resource.Sku.ToJToken().ToPsObject(objectFormat) }, + { "Sku", resource.Sku.ToJToken().ToPsObject() }, }; var resourceTypeName = resourceType == null && extensionResourceType == null @@ -81,17 +80,14 @@ internal static PSObject ToPsObject(this Resource resource, ResourceObje /// Gets the properties object /// /// The object. - /// The - private static object GetProperties(Resource resource, ResourceObjectFormat objectFormat) + private static object GetProperties(Resource resource) { if (resource.Properties == null) { return null; } - return objectFormat == ResourceObjectFormat.Legacy - ? JsonUtilities.DeserializeJson(resource.Properties.ToString()) - : (object)resource.Properties.ToPsObject(objectFormat); + return (object)resource.Properties.ToPsObject(); } /// diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/FindAzureResourceGroupCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/FindAzureResourceGroupCmdlet.cs index 7769128dabe3..fe6cf998b8ec 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/FindAzureResourceGroupCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/FindAzureResourceGroupCmdlet.cs @@ -52,7 +52,7 @@ private void RunCmdlet() getFirstPage: () => this.GetResourceGroups(), getNextPage: nextLink => this.GetNextLink(nextLink), cancellationToken: this.CancellationToken, - action: resourceGroups => this.WriteObject(sendToPipeline: resourceGroups.CoalesceEnumerable().SelectArray(resourceGroup => resourceGroup.ToPsObject(ResourceObjectFormat.New)), enumerateCollection: true)); + action: resourceGroups => this.WriteObject(sendToPipeline: resourceGroups.CoalesceEnumerable().SelectArray(resourceGroup => resourceGroup.ToPsObject()), enumerateCollection: true)); } /// diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs index 7f651538a2c8..50869b58266e 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs @@ -79,7 +79,7 @@ private void RunCmdlet() getFirstPage: () => this.GetResources(), getNextPage: nextLink => this.GetNextLink(nextLink), cancellationToken: this.CancellationToken, - action: resources => this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(resource => resource.ToPsObject(ResourceObjectFormat.New)), enumerateCollection: true)); + action: resources => this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(resource => resource.ToPsObject()), enumerateCollection: true)); } /// diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/InvokeAzureResourceActionCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/InvokeAzureResourceActionCmdlet.cs index 1da27845b24e..4da02ad00e87 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/InvokeAzureResourceActionCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/InvokeAzureResourceActionCmdlet.cs @@ -83,7 +83,7 @@ protected override void OnProcessRecord() var resultString = this.GetLongRunningOperationTracker(activityName: activity, isResourceCreateOrUpdate: false) .WaitOnOperation(operationResult: operationResult); - this.TryConvertAndWriteObject(resultString, ResourceObjectFormat.New); + this.TryConvertAndWriteObject(resultString); }); } diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs index 7a5e2da39c56..c97a3e405c0b 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs @@ -155,7 +155,7 @@ protected PSObject[] GetOutputObjects(params JToken[] resources) .Where(resource => resource != null) .SelectArray(resource => { - var psobject = resource.ToResource().ToPsObject(ResourceObjectFormat.New); + var psobject = resource.ToResource().ToPsObject(); psobject.Properties.Add(new PSNoteProperty("LockId", psobject.Properties["ResourceId"].Value)); return psobject; }); diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs index daf0c8232874..ba523ad3b9d4 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs @@ -49,7 +49,7 @@ protected PSObject[] GetOutputObjects(params JToken[] resources) .Where(resource => resource != null) .SelectArray(resource => { - var psobject = resource.ToResource().ToPsObject(ResourceObjectFormat.New); + var psobject = resource.ToResource().ToPsObject(); psobject.Properties.Add(new PSNoteProperty("PolicyAssignmentId", psobject.Properties["ResourceId"].Value)); return psobject; }); diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs index ffc80a68199a..799c7751ee73 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs @@ -49,7 +49,7 @@ protected PSObject[] GetOutputObjects(params JToken[] resources) .Where(resource => resource != null) .SelectArray(resource => { - var psobject = resource.ToResource().ToPsObject(ResourceObjectFormat.New); + var psobject = resource.ToResource().ToPsObject(); psobject.Properties.Add(new PSNoteProperty("PolicyDefinitionId", psobject.Properties["ResourceId"].Value)); return psobject; }); diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs index d4c419529285..e01a3fb96c61 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs @@ -122,25 +122,11 @@ public sealed class FindAzureResourceCmdlet : ResourceManagerCmdletBase [Parameter(ParameterSetName = FindAzureResourceCmdlet.ListTenantResourcesParameterSet, Mandatory = true, HelpMessage = "Indicates that this is a tenant level operation.")] public SwitchParameter TenantLevel { get; set; } - /// - /// Gets or sets the resource property object format. - /// - [Parameter(Mandatory = false, HelpMessage = "The output format of the resource properties.")] - public ResourceObjectFormat OutputObjectFormat { get; set; } - /// /// Gets or sets the subscription id. /// public Guid? SubscriptionId { get; set; } - /// - /// Initializes a new instance of the class. - /// - public FindAzureResourceCmdlet() - { - this.OutputObjectFormat = ResourceObjectFormat.Legacy; - } - /// /// Collects subscription ids from the pipeline. /// @@ -164,11 +150,6 @@ protected override void OnEndProcessing() /// private void RunCmdlet() { - if(this.OutputObjectFormat == ResourceObjectFormat.Legacy) - { - this.WriteWarning("This cmdlet is using the legacy properties object format. This format is being deprecated. Please use '-OutputObjectFormat New' and update your scripts."); - } - if (!this.TenantLevel) { this.SubscriptionId = DefaultContext.Subscription.Id; @@ -193,14 +174,14 @@ private void RunCmdlet() items = this.GetPopulatedResource(batch).Result; } - var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject(this.OutputObjectFormat)); + var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject()); this.WriteObject(sendToPipeline: powerShellObjects, enumerateCollection: true); } } else { - this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject(this.OutputObjectFormat)), enumerateCollection: true); + this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject()), enumerateCollection: true); } }); diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs index e6b985bc519b..0345481a2d55 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs @@ -173,25 +173,11 @@ public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase [Parameter(ParameterSetName = GetAzureResourceCmdlet.ListTenantResourcesParameterSet, Mandatory = true, HelpMessage = "Indicates that this is a tenant level operation.")] public SwitchParameter TenantLevel { get; set; } - /// - /// Gets or sets the resource property object format. - /// - [Parameter(Mandatory = false, HelpMessage = "The output format of the resource properties.")] - public ResourceObjectFormat OutputObjectFormat { get; set; } - /// /// Gets or sets the subscription id. /// public Guid? SubscriptionId { get; set; } - /// - /// Initializes a new instance of the class. - /// - public GetAzureResourceCmdlet() - { - this.OutputObjectFormat = ResourceObjectFormat.Legacy; - } - /// /// Collects subscription ids from the pipeline. /// @@ -215,11 +201,6 @@ protected override void OnEndProcessing() /// private void RunCmdlet() { - if(this.OutputObjectFormat == ResourceObjectFormat.Legacy) - { - this.WriteWarning("This cmdlet is using the legacy properties object format. This format is being deprecated. Please use '-OutputObjectFormat New' and update your scripts."); - } - if (string.IsNullOrEmpty(this.ResourceId) && !this.TenantLevel) { this.SubscriptionId = DefaultContext.Subscription.Id; @@ -244,14 +225,14 @@ private void RunCmdlet() items = this.GetPopulatedResource(batch).Result; } - var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject(this.OutputObjectFormat)); + var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject()); this.WriteObject(sendToPipeline: powerShellObjects, enumerateCollection: true); } } else { - this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject(this.OutputObjectFormat)), enumerateCollection: true); + this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject()), enumerateCollection: true); } }); diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/MoveAzureResourceCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/MoveAzureResourceCmdlet.cs index 8607250c6ce1..2864b81cb992 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/MoveAzureResourceCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/MoveAzureResourceCmdlet.cs @@ -165,7 +165,7 @@ private void RunCmdlet() isResourceCreateOrUpdate: false) .WaitOnOperation(operationResult: operationResult); - this.TryConvertAndWriteObject(result, ResourceObjectFormat.New); + this.TryConvertAndWriteObject(result); }); } } diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs index ab8ce0bf43c1..5e714d70c870 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs @@ -81,36 +81,16 @@ public sealed class NewAzureResourceCmdlet : ResourceManipulationCmdletBase [Parameter(Mandatory = false, HelpMessage = "When set indicates that the full object is passed in to the -PropertyObject parameter.")] public SwitchParameter IsFullObject { get; set; } - /// - /// Gets or sets the resource property object format. - /// - [Parameter(Mandatory = false, HelpMessage = "The output format of the resource properties.")] - [ValidateNotNull] - public ResourceObjectFormat? OutputObjectFormat { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public NewAzureResourceCmdlet() - { - this.OutputObjectFormat = ResourceObjectFormat.Legacy; - } - /// /// Executes the cmdlet. /// protected override void OnProcessRecord() { base.OnProcessRecord(); - this.DetermineOutputObjectFormat(); if(this.IsFullObject.IsPresent) { this.WriteWarning("The IsFullObject parameter is obsolete and will be removed in future releases."); } - if (this.OutputObjectFormat == ResourceObjectFormat.Legacy) - { - this.WriteWarning("This cmdlet is using the legacy properties object format. This format is being deprecated. Please use '-OutputObjectFormat New' and update your scripts."); - } var resourceId = this.GetResourceId(); this.ConfirmAction( @@ -142,26 +122,10 @@ protected override void OnProcessRecord() var result = this.GetLongRunningOperationTracker(activityName: activity, isResourceCreateOrUpdate: true) .WaitOnOperation(operationResult: operationResult); - this.TryConvertToResourceAndWriteObject(result, this.OutputObjectFormat.Value); + this.TryConvertToResourceAndWriteObject(result); }); } - /// - /// Determines the output object format. - /// - private void DetermineOutputObjectFormat() - { - if (this.Properties != null && this.OutputObjectFormat == null && this.Properties.TypeNames.Any(typeName => typeName.EqualsInsensitively(Constants.MicrosoftAzureResource))) - { - this.OutputObjectFormat = ResourceObjectFormat.New; - } - - if (this.OutputObjectFormat == null) - { - this.OutputObjectFormat = ResourceObjectFormat.Legacy; - } - } - /// /// Gets the resource body from the parameters. /// diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs index cdb94e6ff6dd..a1ac909a9f6d 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs @@ -75,24 +75,12 @@ public sealed class SetAzureResourceCmdlet : ResourceManipulationCmdletBase [Parameter(Mandatory = false, HelpMessage = "When set indicates if an HTTP PATCH should be used to update the object instead of PUT.")] public SwitchParameter UsePatchSemantics { get; set; } - /// - /// Gets or sets the resource property object format. - /// - [Parameter(Mandatory = false, HelpMessage = "The output format of the resource properties.")] - [ValidateNotNull] - public ResourceObjectFormat? OutputObjectFormat { get; set; } - /// /// Executes the cmdlet. /// protected override void OnProcessRecord() { base.OnProcessRecord(); - this.DetermineOutputObjectFormat(); - if (this.OutputObjectFormat == ResourceObjectFormat.Legacy) - { - this.WriteWarning("This cmdlet is using the legacy properties object format. This format is being deprecated. Please use '-OutputObjectFormat New' and update your scripts."); - } if(!string.IsNullOrEmpty(this.ODataQuery)) { @@ -138,26 +126,10 @@ protected override void OnProcessRecord() var result = this.GetLongRunningOperationTracker(activityName: activity, isResourceCreateOrUpdate: true) .WaitOnOperation(operationResult: operationResult); - this.TryConvertToResourceAndWriteObject(result, this.OutputObjectFormat.Value); + this.TryConvertToResourceAndWriteObject(result); }); } - /// - /// Determines the output object format. - /// - private void DetermineOutputObjectFormat() - { - if (this.Properties != null && this.OutputObjectFormat == null && this.Properties.TypeNames.Any(typeName => typeName.EqualsInsensitively(Constants.MicrosoftAzureResource))) - { - this.OutputObjectFormat = ResourceObjectFormat.New; - } - - if (this.OutputObjectFormat == null) - { - this.OutputObjectFormat = ResourceObjectFormat.Legacy; - } - } - /// /// Gets the resource body. /// diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManagerCmdletBase.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManagerCmdletBase.cs index 8413f672cbe5..3844b525bc1e 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManagerCmdletBase.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManagerCmdletBase.cs @@ -276,13 +276,12 @@ private Dictionary GetCmdletHeaders() /// Writes the object /// /// The result as a string - /// The - protected void TryConvertAndWriteObject(string resultString, ResourceObjectFormat objectFormat) + protected void TryConvertAndWriteObject(string resultString) { JToken resultJToken; if (resultString.TryConvertTo(out resultJToken)) { - this.WriteObject(resultJToken, objectFormat); + this.WriteObject(resultJToken); } else { @@ -294,13 +293,12 @@ protected void TryConvertAndWriteObject(string resultString, ResourceObjectForma /// Writes the object /// /// The result as a string - /// The - protected void TryConvertToResourceAndWriteObject(string resultString, ResourceObjectFormat objectFormat) + protected void TryConvertToResourceAndWriteObject(string resultString) { Resource resultResource; if (resultString.TryConvertTo>(out resultResource)) { - this.WriteObject(resultResource.ToPsObject(objectFormat)); + this.WriteObject(resultResource.ToPsObject()); } else { @@ -312,10 +310,9 @@ protected void TryConvertToResourceAndWriteObject(string resultString, ResourceO /// Writes a object as a . /// /// The result of the action. - /// The - protected void WriteObject(JToken result, ResourceObjectFormat objectFormat) + protected void WriteObject(JToken result) { - this.WriteObject(sendToPipeline: result.ToPsObject(objectFormat), enumerateCollection: true); + this.WriteObject(sendToPipeline: result.ToPsObject(), enumerateCollection: true); } /// diff --git a/src/ResourceManager/Resources/Commands.Resources/Microsoft.Azure.Commands.Resources.dll-Help.xml b/src/ResourceManager/Resources/Commands.Resources/Microsoft.Azure.Commands.Resources.dll-Help.xml index 63923c9764d1..99b0a066d1cb 100644 --- a/src/ResourceManager/Resources/Commands.Resources/Microsoft.Azure.Commands.Resources.dll-Help.xml +++ b/src/ResourceManager/Resources/Commands.Resources/Microsoft.Azure.Commands.Resources.dll-Help.xml @@ -1362,99 +1362,64 @@ This command throws ProviderNotFound exception if an invalid resource provider i Get-AzureRmResourceGroup - + Name Specifies the name of the resource group. Wildcards are not permitted. This parameter is optional. The default is all resource groups in the subscription String + + String + + + + - - Profile + + Location - + Specifies the location of the resource group. - AzureProfile + String + + String + + + + Get-AzureRmResourceGroup - - Tag - - Gets resource groups that have the specified Azure tags. Enter a hash table with a Name key or Name and Value keys. Wildcard characters are not supported.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. To add a tag to a resource group, use the Tag parameter of the New-AzureRmResourceGroup or Set-AzureRmResourceGroup cmdlets. To create a predefined tag, use the New-AzureRmTag cmdlet.For help with hash tables in Windows PowerShell, type: Get-Help about_Hashtables. - - Hashtable - - - Detailed + + Id - Return the details of each resource group if specified. + Specifies the id of the resource group. Wildcards are not permitted. This parameter is optional. The default is all resource groups in the subscription - SwitchParameter + String + + String + + + + - - Profile + + Location - + Specifies the location of the resource group. - AzureProfile + String + + String + + + + - - Name - - Specifies the name of the resource group. Wildcards are not permitted. This parameter is optional. The default is all resource groups in the subscription - - String - - String - - - - - - - Profile - - - - AzureProfile - - AzureProfile - - - - - - - Tag - - Gets resource groups that have the specified Azure tags. Enter a hash table with a Name key or Name and Value keys. Wildcard characters are not supported.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. To add a tag to a resource group, use the Tag parameter of the New-AzureRmResourceGroup or Set-AzureRmResourceGroup cmdlets. To create a predefined tag, use the New-AzureRmTag cmdlet.For help with hash tables in Windows PowerShell, type: Get-Help about_Hashtables. - - Hashtable - - Hashtable - - - - - - - Detailed - - Return the details of each resource group if specified. - - SwitchParameter - - SwitchParameter - - - - - @@ -3935,691 +3900,104 @@ AppPermissions : {{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Keywords: azure, azurerm, arm, resource, management, manager, resource, group, template, deployment - - - - - -------------------------- Create new AAD service principal. -------------------------- - - PS C:\> - - New-AzureRmADServicePrincipal -ApplicationId a3dad041-8119-4182-b500-f8f959bf31db - - Creates a new azure active directory service principal. - - - DisplayName Type ObjectId ------------ ---- -------- -NewApplication 61b5d8ea-fdc6-40a2-8d5b-ad447c678d45 - - - - - - - - - - - - - Remove-AzureRmADServicePrincipal - - - - Get-AzureRmADServicePrincipal - - - - New-AzureRmADApplication - - - - Remove-AzureRmADApplication - - - - - - - - New-AzureRmResourceGroup - - Creates an Azure resource group and its resources - - - - - New - AzureResourceGroup - - - - This is the Description section - The New-AzureRmResourceGroup cmdlet creates an Azure resource group and its resources and returns an object that represents the resource group.Use this cmdlet to create a new resource group. To add a deployment to an existing resource group, use the New-AzureRmResourceGroupDeployment cmdlet. To add a resource to an existing resource group, use the New-AzureRmResource cmdlet.An Azure resource is a user-managed Azure entity, such as a database server, database, or web site. An Azure resource group is a collection of Azure resources that are deployed as a unit.You can create a resource group with just a name and location, and then use the New-AzureRmResource cmdlet to create resources and add them to the resource group. However, typically, you use a resource group template, which is a JSON-based model of a resource group for a complex cloud-based service, such as a web portal. You can find many templates in the Azure template gallery (Get-AzureRmResourceGroupGalleryTemplate) and you can create your own templates.To find a gallery template, use the Get-AzureRmResourceGroupGalleryTemplate template cmdlet. To use a gallery template, use the GalleryTemplateIdentity parameter of New-AzureRmResourceGroup to specify the template identity. Or, use the Save-AzureRmResourceGalleryTemplate cmdlet to save the gallery template as a JSON file, and then use the TemplateFile or TemplateUri parameters to provide the name and location of the file.You can also create a custom resource group template, either by typing in a text file or by editing a gallery template. To use a custom template to create a resource group, use TemplateFile or TemplateUri parameters to supply the location and file name.The template includes parameters (placeholders) for configurable property values, likes names and sizes. To specify values for the template parameters, use a JSON-formatted parameter file (TemplateParameterFile parameter) or a hash table of parameter names and values (TemplateParameterObject parameter). Or, you can use the template parameters that are added to the command dynamically as soon as you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required template parameter, the cmdlet prompts you for the value. Template parameter values that you specify at the command line take precedence over template parameter values in a template parameter object or file. - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateParameterObject - - Specifies a hash table of template parameter names and values. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.This parameter is optional. If a template has parameters, you must specify parameter values, but you can use the TemplateParameterObject or the TemplateParameterFile parameters. Or, you can use the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value. - - Hashtable - - - TemplateUri - - Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file, such as by using the Save-AzureRmResourceGroupGalleryTemplate cmdlet. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateParameterObject - - Specifies a hash table of template parameter names and values. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.This parameter is optional. If a template has parameters, you must specify parameter values, but you can use the TemplateParameterObject or the TemplateParameterFile parameters. Or, you can use the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value. - - Hashtable - - - TemplateFile - - Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file, such as by using the Save-AzureRmResourceGroupGalleryTemplate cmdlet.To use this parameter, the subscription must include a storage account where the cmdlet can save the template. By default, this cmdlet uses the current storage account in the subscription, but you can use the StorageAccountName parameter to specify an alternate storage account. If you do not specify a storage account and the subscription does not have a storage account that is designated as "current," the command fails.To create a storage account, use the Switch-AzureMode cmdlet to switch to the Azure module, and then use the New-AzureRmStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureRmSubscription cmdlet. - - String - - - StorageAccountName - - Specifies the name of a storage account in the subscription. New-AzureRmResourceGroup saves the contents of template files in the storage account. This parameter is optional, but a storage account is required when you use the TemplateFile parameter.The default value is the current storage account in the subscription. If you do not specify a storage account and the subscription does not have a current storage account, the command fails.To create a storage account, use a Switch-AzureMode -Name AzureServiceManagement command to switch to the Azure module, and then use the New-AzureRmStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureRmSubscription cmdlet. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateParameterObject - - Specifies a hash table of template parameter names and values. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.This parameter is optional. If a template has parameters, you must specify parameter values, but you can use the TemplateParameterObject or the TemplateParameterFile parameters. Or, you can use the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value. - - Hashtable - - - GalleryTemplateIdentity - - Specifies the identity of a template in the Azure gallery. To find gallery templates, use the Get-AzureRmResourceGroupGalleryTemplate cmdlet. The value of the Identity property of each gallery item is displayed by default. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateParameterFile - - Specifies the path and name of a JSON file with the names and values of the template parameters. This parameter is optional. If a template has parameters, you must specify parameter values, but you can use the TemplateParameterObject or the TemplateParameterFile parameters. Or, you can use the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value. - - String - - - GalleryTemplateIdentity - - Specifies the identity of a template in the Azure gallery. To find gallery templates, use the Get-AzureRmResourceGroupGalleryTemplate cmdlet. The value of the Identity property of each gallery item is displayed by default. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateParameterFile - - Specifies the path and name of a JSON file with the names and values of the template parameters. This parameter is optional. If a template has parameters, you must specify parameter values, but you can use the TemplateParameterObject or the TemplateParameterFile parameters. Or, you can use the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value. - - String - - - TemplateUri - - Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file, such as by using the Save-AzureRmResourceGroupGalleryTemplate cmdlet. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateParameterFile - - Specifies the path and name of a JSON file with the names and values of the template parameters. This parameter is optional. If a template has parameters, you must specify parameter values, but you can use the TemplateParameterObject or the TemplateParameterFile parameters. Or, you can use the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value. - - String - - - TemplateFile - - Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file, such as by using the Save-AzureRmResourceGroupGalleryTemplate cmdlet.To use this parameter, the subscription must include a storage account where the cmdlet can save the template. By default, this cmdlet uses the current storage account in the subscription, but you can use the StorageAccountName parameter to specify an alternate storage account. If you do not specify a storage account and the subscription does not have a storage account that is designated as "current," the command fails.To create a storage account, use the Switch-AzureMode cmdlet to switch to the Azure module, and then use the New-AzureRmStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureRmSubscription cmdlet. - - String - - - StorageAccountName - - Specifies the name of a storage account in the subscription. New-AzureRmResourceGroup saves the contents of template files in the storage account. This parameter is optional, but a storage account is required when you use the TemplateFile parameter.The default value is the current storage account in the subscription. If you do not specify a storage account and the subscription does not have a current storage account, the command fails.To create a storage account, use a Switch-AzureMode -Name AzureServiceManagement command to switch to the Azure module, and then use the New-AzureRmStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureRmSubscription cmdlet. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - GalleryTemplateIdentity - - Specifies the identity of a template in the Azure gallery. To find gallery templates, use the Get-AzureRmResourceGroupGalleryTemplate cmdlet. The value of the Identity property of each gallery item is displayed by default. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - - - New-AzureRmResourceGroup - - Name - - Specifies a name for the resource group. This parameter is required. The resource name must be unique in the subscription.You can use -Name or its alias, -ResourceGroupName.If a resource group with that name already exists, the command prompts you for confirmation before replacing the existing resource group. To suppress the confirmation prompt, use the Force parameter. - - String - - - Location - - Specifies the location of the resource group. This parameter is required. Enter an Azure data center location, such as "West US" or "Southeast Asia".You can place a resource group in any location. The resource group does not have to be in the same location your Azure subscription or the same location as its resources. Resource groups can contain resources from different locations. To determine which location support each resource type, use the Get-AzureRmResourceProvider with the ProviderNamespace parameter cmdlet. - - String - - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - - - Tag - - Applies the specified tags to the new resource group. Enter new tags or predefined tags that you created by using the New-AzureRmTag cmdlet.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. After you assign tags to resources, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value.Every tag must have a Name key. It can also have an optional Value key with one value. To specify a new tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}. To get your predefined tags, use the Get-AzureRmTag cmdlet. - - Hashtable[] - - - Force - - Suppresses the confirmation prompt and overwrites an existing resource group with the same name. By default, New-AzureRmResourceGroup prompts for confirmation before replacing an existing resource group. - - SwitchParameter - - - TemplateFile - - Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file, such as by using the Save-AzureRmResourceGroupGalleryTemplate cmdlet.To use this parameter, the subscription must include a storage account where the cmdlet can save the template. By default, this cmdlet uses the current storage account in the subscription, but you can use the StorageAccountName parameter to specify an alternate storage account. If you do not specify a storage account and the subscription does not have a storage account that is designated as "current," the command fails.To create a storage account, use the Switch-AzureMode cmdlet to switch to the Azure module, and then use the New-AzureRmStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureRmSubscription cmdlet. - - String - - - StorageAccountName - - Specifies the name of a storage account in the subscription. New-AzureRmResourceGroup saves the contents of template files in the storage account. This parameter is optional, but a storage account is required when you use the TemplateFile parameter.The default value is the current storage account in the subscription. If you do not specify a storage account and the subscription does not have a current storage account, the command fails.To create a storage account, use a Switch-AzureMode -Name AzureServiceManagement command to switch to the Azure module, and then use the New-AzureRmStorageAccount cmdlet. To make the a storage account the "current storage account" for the subscription, use the CurrentStorageAccountName parameter of the Set-AzureRmSubscription cmdlet. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Keywords: azure, azurerm, arm, resource, management, manager, resource, group, template, deployment + + + + + -------------------------- Create new AAD service principal. -------------------------- + + PS C:\> + + New-AzureRmADServicePrincipal -ApplicationId a3dad041-8119-4182-b500-f8f959bf31db + + Creates a new azure active directory service principal. + + + DisplayName Type ObjectId +----------- ---- -------- +NewApplication 61b5d8ea-fdc6-40a2-8d5b-ad447c678d45 + + + + + + + + + + + + + Remove-AzureRmADServicePrincipal + + + + Get-AzureRmADServicePrincipal + + + + New-AzureRmADApplication + + + + Remove-AzureRmADApplication + + + + + + + + New-AzureRmResourceGroup + + Creates an Azure resource group and its resources + + + + + New + AzureResourceGroup + + + + This is the Description section + The New-AzureRmResourceGroup cmdlet creates an Azure resource group and its resources and returns an object that represents the resource group.Use this cmdlet to create a new resource group. To add a deployment to an existing resource group, use the New-AzureRmResourceGroupDeployment cmdlet. To add a resource to an existing resource group, use the New-AzureRmResource cmdlet.An Azure resource is a user-managed Azure entity, such as a database server, database, or web site. An Azure resource group is a collection of Azure resources that are deployed as a unit.You can create a resource group with just a name and location, and then use the New-AzureRmResource cmdlet to create resources and add them to the resource group. However, typically, you use a resource group template, which is a JSON-based model of a resource group for a complex cloud-based service, such as a web portal. You can find many templates in the Azure template gallery (Get-AzureRmResourceGroupGalleryTemplate) and you can create your own templates.To find a gallery template, use the Get-AzureRmResourceGroupGalleryTemplate template cmdlet. To use a gallery template, use the GalleryTemplateIdentity parameter of New-AzureRmResourceGroup to specify the template identity. Or, use the Save-AzureRmResourceGalleryTemplate cmdlet to save the gallery template as a JSON file, and then use the TemplateFile or TemplateUri parameters to provide the name and location of the file.You can also create a custom resource group template, either by typing in a text file or by editing a gallery template. To use a custom template to create a resource group, use TemplateFile or TemplateUri parameters to supply the location and file name.The template includes parameters (placeholders) for configurable property values, likes names and sizes. To specify values for the template parameters, use a JSON-formatted parameter file (TemplateParameterFile parameter) or a hash table of parameter names and values (TemplateParameterObject parameter). Or, you can use the template parameters that are added to the command dynamically as soon as you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required template parameter, the cmdlet prompts you for the value. Template parameter values that you specify at the command line take precedence over template parameter values in a template parameter object or file. + + New-AzureRmResourceGroup @@ -4636,13 +4014,6 @@ NewApplication 61b5d8ea-fdc6-40a2 String - - DeploymentName - - Specifies the name of the deployment project for the resource group. Because the deployment properties are defined in a template, this parameter is valid only when you specify a template. This parameter is optional. The default value is the template name without the .json file name extension. - - String - Tag @@ -4657,28 +4028,7 @@ NewApplication 61b5d8ea-fdc6-40a2 SwitchParameter - - TemplateUri - - Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file, such as by using the Save-AzureRmResourceGroupGalleryTemplate cmdlet. - - String - - - TemplateVersion - - Specifies a particular version of the gallery or custom template. Enter the version number, such as "2014-04-01-preview". This parameter is optional. If you specify this parameter, New-AzureRmResourceGroup verifies that the specified template has the matching version and fails if it does not. - - String - - - Profile - - - - AzureProfile - - + @@ -7049,31 +6399,20 @@ PS C:\> New-AzureRmRoleDefinition -Role $roleDef SwitchParameter - - PassThru - - Returns $True if the remove operation was successful and $False if it failed. By default, this cmdlet does not return any output. - - SwitchParameter - - - Profile - - - - AzureProfile - - - WhatIf + + + Remove-AzureRmResourceGroup + + Id - Shows what would happen if the cmdlet runs. The cmdlet is not run. + Specifies the Id of resource groups to delete. This parameter is required. Wildcards are not permitted. - SwitchParameter + String - Confirm + Force - Prompts you for confirmation before running the cmdlet. + Suppresses the confirmation prompt. By default, Remove-AzureRmResource prompts you to confirm before deleting a resource group. SwitchParameter @@ -7093,23 +6432,23 @@ PS C:\> New-AzureRmRoleDefinition -Role $roleDef - - Force + + Id - Suppresses the confirmation prompt. By default, Remove-AzureRmResource prompts you to confirm before deleting a resource group. + Specifies the Id of resource groups to delete. This parameter is required. Wildcards are not permitted. - SwitchParameter + String - SwitchParameter + String - PassThru + Force - Returns $True if the remove operation was successful and $False if it failed. By default, this cmdlet does not return any output. + Suppresses the confirmation prompt. By default, Remove-AzureRmResource prompts you to confirm before deleting a resource group. SwitchParameter @@ -7119,72 +6458,7 @@ PS C:\> New-AzureRmRoleDefinition -Role $roleDef - - Profile - - - - AzureProfile - - AzureProfile - - - - - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - SwitchParameter - - SwitchParameter - - - false - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - SwitchParameter - - SwitchParameter - - - false - - - - - None - - - - - - - - - - - - - - None or System.Boolean - - - - - - - - - - @@ -8482,12 +7756,22 @@ PS C:\>New-AzureRmResourceGroup -Name ContosoRG02 -Location 'South Central US Hashtable[] - - Profile + + + Set-AzureRmResourceGroup + + Id - + Specifies the Id of the resource group. This parameter identifies the resource group that you want to change. - AzureProfile + String + + + Tag + + Replaces the tags for the resource group with the specified tags. To add or change a single tag, you must replace the collection of tags for the resource group.A "tag" is a name-value pair that you can create and apply to resources and resource groups. After you assign tags to resources and groups, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources.Each tag must have a Name key. It can also have an optional Value key with one value. To specify a tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}.To delete a tag, enter a hash table with all tags currently applied to the resource group (from Get-AzureRmResourceGroup), except for the tag you want to delete. To delete all tags from a resource group, enter an empty hash table (-Tag @{}). + + Hashtable[] @@ -8505,27 +7789,27 @@ PS C:\>New-AzureRmResourceGroup -Name ContosoRG02 -Location 'South Central US - - Tag + + Id - Replaces the tags for the resource group with the specified tags. To add or change a single tag, you must replace the collection of tags for the resource group.A "tag" is a name-value pair that you can create and apply to resources and resource groups. After you assign tags to resources and groups, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources.Each tag must have a Name key. It can also have an optional Value key with one value. To specify a tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}.To delete a tag, enter a hash table with all tags currently applied to the resource group (from Get-AzureRmResourceGroup), except for the tag you want to delete. To delete all tags from a resource group, enter an empty hash table (-Tag @{}). + Specifies the Id of the resource group. This parameter identifies the resource group that you want to change. - Hashtable[] + String - Hashtable[] + String - - Profile + + Tag - + Replaces the tags for the resource group with the specified tags. To add or change a single tag, you must replace the collection of tags for the resource group.A "tag" is a name-value pair that you can create and apply to resources and resource groups. After you assign tags to resources and groups, you can use the Tag parameters of Get-AzureRmResource and Get-AzureRmResourceGroup to search for resources and groups by tag name or name and value. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources.Each tag must have a Name key. It can also have an optional Value key with one value. To specify a tag, use a hash table, such as @{Name="FY2015"} or @{Name="Department";Value="IT"}. To specify multiple tags, use commas to separate the hash tables, such as -Tag @{Name="FY2015"}, @{Name="Department";Value="IT"}.To delete a tag, enter a hash table with all tags currently applied to the resource group (from Get-AzureRmResourceGroup), except for the tag you want to delete. To delete all tags from a resource group, enter an empty hash table (-Tag @{}). - AzureProfile + Hashtable[] - AzureProfile + Hashtable[] diff --git a/tools/AzureRM/AzureRM.psm1 b/tools/AzureRM/AzureRM.psm1 index ea4f44e438c4..1aa94cc1340d 100644 --- a/tools/AzureRM/AzureRM.psm1 +++ b/tools/AzureRM/AzureRM.psm1 @@ -1,4 +1,4 @@ -$AzureMajorVersion = "0"; +$AzureMajorVersion = "0" $AzureRMModules = @( "AzureRM.ApiManagement", @@ -42,12 +42,13 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str { $_MinVer = "$MajorVersion.0.0.0" $_MaxVer = "$MajorVersion.9999.9999.9999" + $script:InstallCounter ++ try { $_ExistingModule = Get-Module -ListAvailable -Name $Name $_ModuleAction = "installed" if ($_ExistingModule -ne $null) { - Update-Module -Name $Name -MaximumVersion $_MaxVer -ErrorAction Stop + Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force -ErrorAction Stop $_ModuleAction = "updated" } else @@ -55,7 +56,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -ErrorAction Stop } $v = (Get-InstalledModule -Name $Name -ErrorAction Ignore)[0].Version.ToString() - Write-Output "$Name $v $_ModuleAction..." + Write-Output "$Name $v $_ModuleAction [$script:InstallCounter/$($AzureRMModules.Count + 1)]..." } catch { Write-Warning "Skipping $Name package..." Write-Warning $_ @@ -96,29 +97,22 @@ function Update-AzureRM Write-Output "Installing AzureRM modules." - $_InstallationPolicy = (Get-PSRepository -Name PSGallery).InstallationPolicy + $_InstallationPolicy = (Get-PSRepository -Name $Repository).InstallationPolicy + $script:InstallCounter = 0 try { - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + Set-PSRepository -Name $Repository -InstallationPolicy Trusted Install-ModuleWithVersionCheck "AzureRM.Profile" $MajorVersion $Repository $Scope - # Stop and remove any previous jobs - $AzureRMModules | ForEach {Get-Job -Name "*$_"} | Stop-Job | Remove-Job - # Start new job - $result = $AzureRMModules | ForEach { - Start-Job -Name $_ -ScriptBlock { - Install-ModuleWithVersionCheck $args[0] $args[1] $args[2] $args[3] - } -ArgumentList $_, $MajorVersion, $Repository, $Scope } - - # Get results from the jobs - $AzureRMModules | ForEach {Get-Job -Name $_ | Wait-Job | Receive-Job } + $AzureRMModules | ForEach { + Install-ModuleWithVersionCheck $_ $MajorVersion $Repository $Scope + } } finally { # Clean up - Set-PSRepository -Name PSGallery -InstallationPolicy $_InstallationPolicy - $AzureRMModules | ForEach {Get-Job -Name $_ | Remove-Job} + Set-PSRepository -Name $Repository -InstallationPolicy $_InstallationPolicy } } @@ -167,11 +161,15 @@ function Uninstall-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion) $_MatchedModule = Get-InstalledModule -Name $Name -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -ErrorAction Ignore | where {$_.Name -eq $Name} if ($_MatchedModule -ne $null) { try { - Remove-Module -Name $_MatchedModule.Name -Force -ErrorAction Ignore - Uninstall-Module -Name $_MatchedModule.Name -RequiredVersion $_MatchedModule.Version -Confirm:$false -ErrorAction Stop - if ((Get-Module -Name $_MatchedModule.Name | where {$_.Version -eq $_MatchedModule.Version}) -eq $null) + Remove-Module -Name $Name -Force -ErrorAction Ignore + Uninstall-Module -Name $Name -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Confirm:$false -ErrorAction Stop + if ((Get-Module -Name $Name -ListAvailable) -eq $null) + { + Write-Output "$Name uninstalled..." + } + else { - Write-Output "$Name version $($_MatchedModule.Version) uninstalled..." + Write-Output "$Name partially uninstalled..." } } catch { Write-Warning "Skipping $Name package..."