Skip to content

Merging master into Preview #6478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
## 6.2.1 - June 2018
## 6.3.0 - June 2018
#### AzureRM.Profile
* Updated error messages for Enable-AzureRmContextAutoSave
* Create a context for each subscription when running 'Connect-AzureRmAccount' with no previous context

#### Azure.Storage
* Added additional information about -Permissions parameter in help files.

#### AzureRM.Compute
* 'Get-AzureRmVmDiskEncryptionStatus' fixes an issue observed for VMs with no data disks
* Update Compute client library version to fix following cmdlets
- Grant-AzureRmDiskAccess
- Grant-AzureRmSnapshotAccess
- Save-AzureRmVMImage
* Fixed following cmdlets to show 'operation ID' and 'operation status' correctly:
- Start-AzureRmVM
- Stop-AzureRmVM
- Restart-AzureRmVM
- Set-AzureRmVM
- Remove-AzuerRmVM
- Set-AzureRmVmss
- Start-AzureRmVmssRollingOSUpgrade
- Stop-AzureRmVmssRollingUpgrade
- Start-AzureRmVmss
- Restart-AzureRmVmss
- Stop-AzureRmVmss
- Remove-AzureRmVmss
- ConvertTo-AzureRmVMManagedDisk
- Revoke-AzureRmSnapshotAccess
- Remove-AzureRmSnapshot
- Revoke-AzureRmDiskAccess
- Remove-AzureRmDisk
- Remove-AzureRmContainerService
- Remove-AzureRmAvailabilitySet

#### AzureRM.EventGrid
* Remove ValidateNotNullOrEmpty validation conditions for SubjectBeginsWith/SubjectEndsWith in Update-AzureRmEventGridSubscription cmdlet to allow changing these parameters to empty string if needed.

#### AzureRM.KeyVault
* Fix issue where no Tags are being returned when Get-AzureRmKeyVault -Tag is run

#### AzureRM.PolicyInsights
* Public release of Policy Insights cmdlets
- Use API version 2018-04-04
- Add PolicyDefinitionReferenceId to the results of Get-AzureRmPolicyStateSummary

#### AzureRM.RecoveryServices.Backup
* Added -Vault parameter to RecoveryServices.Backup cmdlets. When passed, this will override the Set-AzureRmRecoveryServicesContext cmdlet.

#### AzureRM.Sql
* Updated example in the help file for Get-AzureRmSqlDatabaseExpanded

#### AzureRM.TrafficManager
* Updated the help file for Add-AzureRmTrafficManagerEndpointConfig

#### AzureRM.Websites
* 'Set-AzureRmWebApp' is updated to not overwrite the AppSettings when using -AssignIdentity
* 'New-AzureRmWebAppSlot' is updated to honor AppServicePlan as an optional parameter

## 6.2.1 - June 2018
### AzureRM.OperationalInsights
* Updated PSWorkspace model to allow Network to use type as a parameter

Expand Down
4 changes: 2 additions & 2 deletions src/Common/Commands.Common/AzurePowerShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class AzurePowerShell

public const string AssemblyCopyright = "Copyright © Microsoft";

public const string AssemblyVersion = "6.2.1";
public const string AssemblyVersion = "6.3.0";

public const string AssemblyFileVersion = "6.2.1";
public const string AssemblyFileVersion = "6.3.0";

public const string ProfileFile = "AzureProfile.json";

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Aks/AzureRM.Aks.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\YamlDotNet.dll',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.Analysis.dll'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ CLRVersion='4.0'
ProcessorArchitecture = 'None'

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\AutoMapper.dll',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.ApplicationInsights.dll'
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Automation/AzureRM.Automation.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.Automation.dll'
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/AzureBackup/AzureRM.Backup.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.BackupServicesManagement.dll',
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/AzureBatch/AzureRM.Batch.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Batch.dll',
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Billing/AzureRM.Billing.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.Billing.dll'
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Cdn/AzureRM.Cdn.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.Cdn.dll'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.CognitiveServices.dll'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Management.Internal.Resources;
using Microsoft.Azure.Management.Internal.Resources.Models;
using Microsoft.Rest.Azure.OData;

namespace Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class ResourceIdCompleterAttribute : ArgumentCompleterAttribute
{
private static readonly object Lock = new object();

/// <summary>
/// Consturctor
/// </summary>
/// <param name="resourceType">Azure recource type</param>
public ResourceIdCompleterAttribute(string resourceType)
: base(CreateScriptBlock(resourceType))
{}

public static ScriptBlock CreateScriptBlock(string resourceType)
{
string script = "param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\n" +
$"$resourceType = \"{resourceType}\"\n" +
"$resourceIds = [Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceIdCompleterAttribute]::GetResourceIds($resourceType)\n" +
"$resourceIds | Where-Object { $_ -Like \"*$wordToComplete*\" } | Sort-Object | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }";
var scriptBlock = ScriptBlock.Create(script);
return scriptBlock;
}

private class CacheItem
{
public DateTime Timestamp { get; set; }
public IEnumerable<string> ResourceInfoList { get; set; }
}

private static readonly IDictionary<int, CacheItem> Cache = new Dictionary<int, CacheItem>();

public static TimeSpan TimeToUpdate { get; set; } = TimeSpan.FromMinutes(5);

public static TimeSpan RequestTimeout { get; set; } = TimeSpan.FromSeconds(3);

public static IEnumerable<string> GetResourceIds(string resourceType)
{
lock (Lock)
{
var context = AzureRmProfileProvider.Instance.Profile.DefaultContext;
var contextHash = HashContext(context, resourceType);
var cacheItem = Cache.ContainsKey(contextHash) ? Cache[contextHash] : null;

if (cacheItem != null && DateTime.Now.Subtract(cacheItem.Timestamp).CompareTo(TimeToUpdate) < 0)
{
return Cache[contextHash].ResourceInfoList;
}

var client = AzureSession.Instance.ClientFactory.CreateArmClient<ResourceManagementClient>(context, AzureEnvironment.Endpoint.ResourceManager);

var odata = new ODataQuery<GenericResourceFilter>(r => r.ResourceType == resourceType);

IEnumerable<string> resourceInfoList = new List<string>();

try
{
using (var cancelSource = new CancellationTokenSource())
{
var task = client.Resources.ListAsync(odata, cancelSource.Token);

if (!task.Wait(RequestTimeout))
{
cancelSource.Cancel();
return resourceInfoList;
}

var result = task.Result;
resourceInfoList = result
.Select(r => r.Id)
.ToList();
}
}
catch (Exception)
{
return resourceInfoList;
}

if (cacheItem != null)
{
cacheItem.Timestamp = DateTime.Now;
cacheItem.ResourceInfoList = resourceInfoList;
Cache[contextHash] = cacheItem;
}
else
{
Cache.Add(contextHash, new CacheItem
{
Timestamp = DateTime.Now,
ResourceInfoList = resourceInfoList
});
}

return resourceInfoList;
}
}

private static int HashContext(IAzureContext context, string resourceType)
{
return (context.Account.Id + context.Environment.Name + context.Subscription.Id + context.Tenant.Id + resourceType).GetHashCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<ItemGroup>
<Compile Include="AccessTokenExtensions.cs" />
<Compile Include="ArgumentCompleters\PSArgumentCompleter.cs" />
<Compile Include="ArgumentCompleters\ResourceIdCompleter.cs" />
<Compile Include="ArgumentCompleters\ResourceTypeCompleter.cs" />
<Compile Include="ArgumentCompleters\ScopeCompleter.cs" />
<Compile Include="AzureRmCmdlet.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Data.Edm.dll', '.\Microsoft.Data.OData.dll',
Expand Down
34 changes: 28 additions & 6 deletions src/ResourceManager/Compute/AzureRM.Compute.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 5/29/2018
# Generated on: 6/12/2018
#

@{
Expand All @@ -12,7 +12,7 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '5.1.0'
ModuleVersion = '5.1.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.2.0'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\AutoMapper.dll', '.\Microsoft.Azure.Management.Compute.dll',
Expand Down Expand Up @@ -215,9 +215,31 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* VMSS VM Update feature
- Added ''Update-AzureRmVmssVM'' and ''New-AzureRmVMDataDisk'' cmdlets
- Add VirtualMachineScaleSetVM parameter to ''Add-AzureRmVMDataDisk'' cmdlet to support adding a data disk to Vmss VM.'
ReleaseNotes = '* ''Get-AzureRmVmDiskEncryptionStatus'' fixes an issue observed for VMs with no data disks
* Update Compute client library version to fix following cmdlets
- Grant-AzureRmDiskAccess
- Grant-AzureRmSnapshotAccess
- Save-AzureRmVMImage
* Fixed following cmdlets to show ''operation ID'' and ''operation status'' correctly:
- Start-AzureRmVM
- Stop-AzureRmVM
- Restart-AzureRmVM
- Set-AzureRmVM
- Remove-AzuerRmVM
- Set-AzureRmVmss
- Start-AzureRmVmssRollingOSUpgrade
- Stop-AzureRmVmssRollingUpgrade
- Start-AzureRmVmss
- Restart-AzureRmVmss
- Stop-AzureRmVmss
- Remove-AzureRmVmss
- ConvertTo-AzureRmVMManagedDisk
- Revoke-AzureRmSnapshotAccess
- Remove-AzureRmSnapshot
- Revoke-AzureRmDiskAccess
- Remove-AzureRmDisk
- Remove-AzureRmContainerService
- Remove-AzureRmAvailabilitySet'

# Prerelease string of this module
# Prerelease = ''
Expand Down
Loading