diff --git a/setup/azurecmdfiles.wxi b/setup/azurecmdfiles.wxi index 98ef6a02cf1f..672cd10e5031 100644 --- a/setup/azurecmdfiles.wxi +++ b/setup/azurecmdfiles.wxi @@ -8,6 +8,9 @@ + + + @@ -50,6 +53,15 @@ + + + + + + + + + @@ -109,6 +121,9 @@ + + + @@ -169,6 +184,15 @@ + + + + + + + + + @@ -198,6 +222,9 @@ + + + @@ -240,6 +267,15 @@ + + + + + + + + + @@ -250,152 +286,176 @@ - - - + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + - - - + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + @@ -405,6 +465,21 @@ + + + + + + + + + + + + + + + @@ -528,6 +603,15 @@ + + + + + + + + + @@ -560,6 +644,9 @@ + + + @@ -620,6 +707,15 @@ + + + + + + + + + @@ -640,6 +736,12 @@ + + + + + + @@ -700,6 +802,9 @@ + + + @@ -714,6 +819,9 @@ + + + @@ -771,6 +879,15 @@ + + + + + + + + + @@ -785,6 +902,9 @@ + + + @@ -853,6 +973,15 @@ + + + + + + + + + @@ -937,6 +1066,15 @@ + + + + + + + + + @@ -963,6 +1101,15 @@ + + + + + + + + + @@ -1050,6 +1197,15 @@ + + + + + + + + + @@ -1070,6 +1226,9 @@ + + + @@ -1115,6 +1274,15 @@ + + + + + + + + + @@ -1129,6 +1297,9 @@ + + + @@ -1171,6 +1342,15 @@ + + + + + + + + + @@ -1185,6 +1365,9 @@ + + + @@ -1230,6 +1413,15 @@ + + + + + + + + + @@ -1244,6 +1436,12 @@ + + + + + + @@ -1310,6 +1508,15 @@ + + + + + + + + + @@ -1330,6 +1537,9 @@ + + + @@ -1372,6 +1582,15 @@ + + + + + + + + + @@ -1392,6 +1611,15 @@ + + + + + + + + + @@ -1482,6 +1710,9 @@ + + + @@ -1510,99 +1741,120 @@ - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1680,6 +1932,9 @@ + + + @@ -1722,9 +1977,15 @@ + + + + + + @@ -1739,6 +2000,12 @@ + + + + + + @@ -1792,6 +2059,9 @@ + + + @@ -1837,11 +2107,23 @@ + + + + + + + + + + + + @@ -1893,6 +2175,15 @@ + + + + + + + + + @@ -1953,6 +2244,15 @@ + + + + + + + + + @@ -1976,6 +2276,9 @@ + + + @@ -2018,6 +2321,15 @@ + + + + + + + + + @@ -2125,6 +2437,15 @@ + + + + + + + + + @@ -2283,6 +2604,15 @@ + + + + + + + + + @@ -2363,6 +2693,15 @@ + + + + + + + + + @@ -2467,6 +2806,15 @@ + + + + + + + + + @@ -2607,6 +2955,9 @@ + + + @@ -2966,6 +3317,15 @@ + + + + + + + + + @@ -3039,6 +3399,15 @@ + + + + + + + + + @@ -3137,6 +3506,15 @@ + + + + + + + + + @@ -3463,6 +3841,9 @@ + + + @@ -3505,6 +3886,15 @@ + + + + + + + + + @@ -3654,6 +4044,15 @@ + + + + + + + + + @@ -3731,6 +4130,15 @@ + + + + + + + + + @@ -3772,6 +4180,7 @@ + @@ -3786,6 +4195,9 @@ + + + @@ -3805,6 +4217,7 @@ + @@ -3825,6 +4238,9 @@ + + + @@ -3834,6 +4250,7 @@ + @@ -3848,59 +4265,75 @@ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3942,6 +4375,9 @@ + + + @@ -3952,6 +4388,7 @@ + @@ -3972,12 +4409,17 @@ + + + + + @@ -3998,10 +4440,12 @@ + + @@ -4021,10 +4465,14 @@ + + + + @@ -4047,6 +4495,9 @@ + + + @@ -4075,6 +4526,9 @@ + + + @@ -4083,6 +4537,9 @@ + + + @@ -4112,12 +4569,16 @@ + + + + @@ -4133,10 +4594,14 @@ + + + + @@ -4151,10 +4616,14 @@ + + + + @@ -4170,10 +4639,15 @@ + + + + + @@ -4196,12 +4670,16 @@ + + + + @@ -4216,12 +4694,18 @@ + + + + + + @@ -4252,6 +4736,7 @@ + @@ -4261,36 +4746,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4316,6 +4808,7 @@ + @@ -4330,11 +4823,15 @@ + + + + @@ -4352,6 +4849,7 @@ + @@ -4367,7 +4865,11 @@ + + + + @@ -4385,6 +4887,9 @@ + + + @@ -4403,6 +4908,9 @@ + + + @@ -4410,6 +4918,7 @@ + @@ -4424,6 +4933,9 @@ + + + @@ -4459,6 +4971,9 @@ + + + @@ -4511,6 +5026,9 @@ + + + @@ -4537,6 +5055,9 @@ + + + @@ -4571,6 +5092,9 @@ + + + @@ -4617,6 +5141,7 @@ + @@ -4726,6 +5251,9 @@ + + + @@ -4749,6 +5277,9 @@ + + + @@ -4781,6 +5312,9 @@ + + + @@ -4879,6 +5413,7 @@ + @@ -4893,6 +5428,9 @@ + + + @@ -4942,6 +5480,9 @@ + + + @@ -4967,6 +5508,9 @@ + + + diff --git a/src/Common/Storage/Azure.Storage.psd1 b/src/Common/Storage/Azure.Storage.psd1 index 27e92ce5e999..d8088f9b1a3f 100644 --- a/src/Common/Storage/Azure.Storage.psd1 +++ b/src/Common/Storage/Azure.Storage.psd1 @@ -55,17 +55,17 @@ ScriptsToProcess = @() # Type files (.ps1xml) to be loaded when importing this module TypesToProcess = @( - '.\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml' + '.\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml' ) # Format files (.ps1xml) to be loaded when importing this module FormatsToProcess = @( - '.\Microsoft.WindowsAzure.Commands.Storage.format.ps1xml' + '.\Microsoft.WindowsAzure.Commands.Storage.format.ps1xml' ) # Modules to import as nested modules of the module specified in ModuleToProcess NestedModules = @( - '.\Microsoft.WindowsAzure.Commands.Storage.dll', + '.\Microsoft.WindowsAzure.Commands.Storage.dll' ) # Functions to export from this module @@ -79,7 +79,7 @@ VariablesToExport = '*' # Aliases to export from this module AliasesToExport = @( - 'Get-AzureRMStorageContainerAcl', + 'Get-AzureRMStorageContainerAcl', 'Start-CopyAzureStorageBlob', 'Stop-CopyAzureStorageBlob' ) diff --git a/src/ResourceManager/AzureBackup/AzureRM.AzureBackup.psd1 b/src/ResourceManager/AzureBackup/AzureRM.Backup.psd1 similarity index 100% rename from src/ResourceManager/AzureBackup/AzureRM.AzureBackup.psd1 rename to src/ResourceManager/AzureBackup/AzureRM.Backup.psd1 diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj index dd4ab033e045..34b48d313a86 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj @@ -19,7 +19,7 @@ true full false - ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.AzureBackup\ + ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Backup\ DEBUG;TRACE prompt 4 @@ -30,7 +30,7 @@ MinimumRecommendedRules.ruleset - ..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.AzureBackup\ + ..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Backup\ TRACE;SIGN true pdbonly @@ -192,8 +192,8 @@ - - AzureRM.AzureBackup.psd1 + + AzureRM.Backup.psd1 PreserveNewest diff --git a/src/ResourceManager/AzureBatch/Commands.Batch/Commands.Batch.csproj b/src/ResourceManager/AzureBatch/Commands.Batch/Commands.Batch.csproj index 00f179186b58..2f77d199352c 100644 --- a/src/ResourceManager/AzureBatch/Commands.Batch/Commands.Batch.csproj +++ b/src/ResourceManager/AzureBatch/Commands.Batch/Commands.Batch.csproj @@ -19,7 +19,7 @@ true full false - ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.AzureBatch\ + ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Batch\ TRACE;DEBUG;CODE_ANALYSIS prompt 4 @@ -30,7 +30,7 @@ pdbonly true - ..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.AzureBatch\ + ..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Batch\ TRACE;SIGN prompt 4 diff --git a/src/ResourceManager/OperationalInsights/AzureRM.OperationalInsights.psd1 b/src/ResourceManager/OperationalInsights/AzureRM.OperationalInsights.psd1 index 88631a18c9cd..3c7ed013faf3 100644 --- a/src/ResourceManager/OperationalInsights/AzureRM.OperationalInsights.psd1 +++ b/src/ResourceManager/OperationalInsights/AzureRM.OperationalInsights.psd1 @@ -58,7 +58,7 @@ TypesToProcess = @() # Format files (.ps1xml) to be loaded when importing this module FormatsToProcess = @( - '.\Microsoft.Azure.Commands.OperationalInsights.format.ps1xml' + '.\Microsoft.Azure.Commands.OperationalInsights.format.ps1xml' ) # Modules to import as nested modules of the module specified in ModuleToProcess diff --git a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Commands.OperationalInsights.csproj b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Commands.OperationalInsights.csproj index 9086ec747cdc..69dabcffb636 100644 --- a/src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Commands.OperationalInsights.csproj +++ b/src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Commands.OperationalInsights.csproj @@ -164,6 +164,7 @@ AzureRM.OperationalInsights.psd1 + PreserveNewest diff --git a/src/ResourceManager/Resources/AzureRM.Resources.psd1 b/src/ResourceManager/Resources/AzureRM.Resources.psd1 index 823fb009342b..54d68824b41b 100644 --- a/src/ResourceManager/Resources/AzureRM.Resources.psd1 +++ b/src/ResourceManager/Resources/AzureRM.Resources.psd1 @@ -64,7 +64,7 @@ FormatsToProcess = @( # Modules to import as nested modules of the module specified in ModuleToProcess NestedModules = @( '.\Microsoft.Azure.Commands.Resources.dll', - '.\Microsoft.Azure.Commands.ResourceManager.Cmdlets.dll', + '.\Microsoft.Azure.Commands.ResourceManager.Cmdlets.dll' ) # Functions to export from this module diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceCmdlet.cs index 6a8396fe7a2a..b636eaa36979 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/GetAzureResourceCmdlet.cs @@ -103,13 +103,6 @@ public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase [ValidateNotNullOrEmpty] public string ResourceType { get; set; } - /// - /// Gets or sets the deprecated parent resource parameter. - /// - [Parameter(ParameterSetName = GetAzureResourceCmdlet.GetResourceParameterSet, Mandatory = false, ValueFromPipelineByPropertyName = false, HelpMessage = "The parent resource type. e.g. Servers/myServer.")] - [ValidateNotNullOrEmpty] - public string ParentResource { get; set; } - /// /// Gets or sets the extension resource name parameter. /// @@ -132,34 +125,12 @@ public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase [ValidateNotNullOrEmpty] public string ExtensionResourceType { get; set; } - /// - /// Gets or sets the tag name. - /// - [Parameter(ParameterSetName = GetAzureResourceCmdlet.ListResourcesParameterSet, Mandatory = false, HelpMessage = "The name of the tag to query by.")] - [Parameter(ParameterSetName = GetAzureResourceCmdlet.MultiSubscriptionListResourcesParameterSet, Mandatory = false, HelpMessage = "The name of the tag to query by.")] - [ValidateNotNullOrEmpty] - public string TagName { get; set; } - - /// - /// Gets or sets the tag value. - /// - [Parameter(ParameterSetName = GetAzureResourceCmdlet.ListResourcesParameterSet, Mandatory = false, HelpMessage = "The value of the tag to query by.")] - [Parameter(ParameterSetName = GetAzureResourceCmdlet.MultiSubscriptionListResourcesParameterSet, Mandatory = false, HelpMessage = "The value of the tag to query by.")] - [ValidateNotNullOrEmpty] - public string TagValue { get; set; } - /// /// Gets or sets the expand properties property. /// [Parameter(Mandatory = false, HelpMessage = "When specified, expands the properties of the resource.")] public SwitchParameter ExpandProperties { get; set; } - /// - /// Gets or sets the expand permissions property. - /// - [Parameter(Mandatory = false, HelpMessage = "When specified, expands the permissions on the resource.")] - public SwitchParameter ExpandPermissions { get; set; } - /// /// Gets or sets the is collection. /// @@ -186,15 +157,6 @@ public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase [ValidateNotNullOrEmpty] public string ODataQuery { get; set; } - /// - /// Gets or sets the subscription ids. - /// - [Parameter(Mandatory = false, ParameterSetName = GetAzureResourceCmdlet.GetResourceParameterSet, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The subscription to use.")] - [Parameter(Mandatory = false, ParameterSetName = GetAzureResourceCmdlet.ListResourcesParameterSet, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The subscription to use.")] - [Parameter(Mandatory = true, ParameterSetName = GetAzureResourceCmdlet.MultiSubscriptionListResourcesParameterSet, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The subscription to use.")] - [ValidateNotNullOrEmpty] - public Guid[] SubscriptionId { get; set; } - /// /// Gets or sets the resource group name. /// @@ -217,12 +179,21 @@ public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase [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; + if(string.IsNullOrEmpty(this.ResourceId)) + { + this.SubscriptionId = DefaultContext.Subscription.Id; + } } /// @@ -231,19 +202,6 @@ public GetAzureResourceCmdlet() protected override void OnProcessRecord() { base.OnProcessRecord(); - if(!string.IsNullOrEmpty(this.TagName) || !string.IsNullOrEmpty(this.TagValue)) - { - this.WriteWarning("The TagName and TagValue parameters are obsolete and will be removed in future releases."); - } - if(!string.IsNullOrEmpty(this.ParentResource)) - { - this.WriteWarning("The ParentResource parameter is obsolete and will be removed in future releases. Please use the -ResourceType and -ResourceName parameters instead."); - } - if (this.ExpandPermissions.IsPresent) - { - this.WriteWarning("The ExpandPermissions parameter is obsolete and will be removed in future releases."); - } - this.subscriptionIds.AddRange(this.SubscriptionId.CoalesceEnumerable()); } /// @@ -253,12 +211,6 @@ protected override void OnEndProcessing() { base.OnEndProcessing(); - this.SubscriptionId = this.subscriptionIds.DistinctArray(); - if (string.IsNullOrWhiteSpace(this.ResourceId) && !this.SubscriptionId.CoalesceEnumerable().Any() && !this.TenantLevel) - { - this.SubscriptionId = DefaultContext.Subscription.Id.AsArray(); - } - this.RunCmdlet(); } @@ -292,10 +244,6 @@ private void RunCmdlet() } var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject(this.OutputObjectFormat)); - if (this.ExpandPermissions) - { - this.PopulatePermissions(powerShellObjects).Wait(); - } this.WriteObject(sendToPipeline: powerShellObjects, enumerateCollection: true); } @@ -354,9 +302,7 @@ private async Task GetResource() { #pragma warning disable 618 - var resourceId = string.IsNullOrWhiteSpace(this.ParentResource) - ? this.GetResourceId() - : this.GetResourceIdWithParentResource(); + var resourceId = this.GetResourceId(); #pragma warning restore 618 @@ -387,7 +333,7 @@ private async Task GetResource() private async Task> ListResourcesTypeCollection() { var resourceCollectionId = ResourceIdUtility.GetResourceId( - subscriptionId: this.SubscriptionId.CoalesceEnumerable().Cast().FirstOrDefault(), + subscriptionId: this.SubscriptionId, resourceGroupName: this.ResourceGroupName, resourceType: this.ResourceType, resourceName: this.ResourceName, @@ -401,8 +347,8 @@ private async Task> ListResourcesTypeCollect var odataQuery = QueryFilterBuilder.CreateFilter( resourceType: null, resourceName: null, - tagName: this.TagName, - tagValue: this.TagValue, + tagName: null, + tagValue: null, filter: this.ODataQuery); return await this @@ -422,12 +368,12 @@ private async Task> ListResourcesInTenant() { var filterQuery = QueryFilterBuilder .CreateFilter( - subscriptionIds: this.SubscriptionId, + subscriptionIds: new Guid[] { this.SubscriptionId }, resourceGroup: this.ResourceGroupName, resourceType: this.ResourceType, resourceName: this.ResourceName, - tagName: this.TagName, - tagValue: this.TagValue, + tagName: null, + tagValue: null, filter: this.ODataQuery); var apiVersion = await this @@ -453,8 +399,8 @@ private async Task> ListResourcesInResourceG .CreateFilter( resourceType: this.ResourceType, resourceName: this.ResourceName, - tagName: this.TagName, - tagValue: this.TagValue, + tagName: null, + tagValue: null, filter: this.ODataQuery); var apiVersion = await this @@ -464,7 +410,7 @@ private async Task> ListResourcesInResourceG return await this .GetResourcesClient() .ListResources( - subscriptionId: this.SubscriptionId.Single(), + subscriptionId: this.SubscriptionId, resourceGroupName: this.ResourceGroupName, apiVersion: apiVersion, top: this.Top, @@ -482,8 +428,8 @@ private async Task> ListResourcesInSubscript .CreateFilter( resourceType: this.ResourceType, resourceName: this.ResourceName, - tagName: this.TagName, - tagValue: this.TagValue, + tagName: null, + tagValue: null, filter: this.ODataQuery); var apiVersion = await this @@ -493,7 +439,7 @@ private async Task> ListResourcesInSubscript return await this .GetResourcesClient() .ListResources( - subscriptionId: this.SubscriptionId.Single(), + subscriptionId: this.SubscriptionId, apiVersion: apiVersion, top: this.Top, filter: filterQuery, @@ -512,85 +458,6 @@ private Task> GetNextLink(string nextLi .ListNextBatch(nextLink: nextLink, cancellationToken: this.CancellationToken.Value); } - /// - /// Populates the permissions on an array of resources. - /// - /// The resources. - private async Task PopulatePermissions(PSObject[] resources) - { - foreach (var batch in resources.Batch()) - { - await batch - .Select(resource => this.PopulatePermissions(resource: resource)) - .WhenAllForAwait() - .ConfigureAwait(continueOnCapturedContext: false); - } - } - - /// - /// Populates the permissions on the resource. - /// - /// The resource. - private async Task PopulatePermissions(PSObject resource) - { - try - { - var resourceId = resource.Properties["ResourceId"].Value.ToString(); - - var resourceCollectionId = resourceId + ResourceIdUtility - .GetResourceCollectionId( - subscriptionId: null, - resourceGroupName: null, - resourceType: null, - extensionResourceType: "Microsoft.Authorization/permissions"); - - var apiVersion = await ApiVersionHelper - .DetermineApiVersion( - DefaultContext, - providerNamespace: "Microsoft.Authorization", - resourceType: "permissions", - cancellationToken: this.CancellationToken.Value, - pre: this.Pre) - .ConfigureAwait(continueOnCapturedContext: false); - - var permissions = PaginatedResponseHelper.Enumerate( - getFirstPage: () => this.GetPermissions(permissionCheckId: resourceCollectionId, apiVersion: apiVersion), - getNextPage: nextLink => this.GetNextLink(nextLink), - cancellationToken: this.CancellationToken); - - resource.Properties.Add(new PSNoteProperty("Permissions", permissions)); - } - catch (Exception ex) - { - if (ex.IsFatal()) - { - throw; - } - - ex = (ex is AggregateException) - ? (ex as AggregateException).Flatten() - : ex; - - this.errors.Add(new ErrorRecord(ex, "ErrorExpandingPermissions", ErrorCategory.CloseError, resource)); - } - } - - /// - /// Gets the permission. - /// - /// The permission check Id. - /// The api version. - /// - private Task> GetPermissions(string permissionCheckId, string apiVersion) - { - return this - .GetResourcesClient() - .ListObjectColleciton( - resourceCollectionId: permissionCheckId, - apiVersion: apiVersion, - cancellationToken: this.CancellationToken.Value); - } - /// /// Populates the properties on an array of resources. /// @@ -652,7 +519,7 @@ private string GetResourceId() return !string.IsNullOrWhiteSpace(this.ResourceId) ? this.ResourceId : ResourceIdUtility.GetResourceId( - subscriptionId: this.SubscriptionId.CoalesceEnumerable().Cast().FirstOrDefault(), + subscriptionId: this.SubscriptionId, resourceGroupName: this.ResourceGroupName, resourceType: this.ResourceType, resourceName: this.ResourceName, @@ -660,28 +527,6 @@ private string GetResourceId() extensionResourceName: this.ExtensionResourceName); } - /// - /// Gets the resource Id using the ParentResource. - /// - private string GetResourceIdWithParentResource() - { - if (this.SubscriptionId.Length != 1) - { - throw new ArgumentException(); - } - -#pragma warning disable 618 - - return ResourceIdUtility.GetResourceId( - subscriptionId: this.SubscriptionId.First(), - resourceGroupName: this.ResourceGroupName, - parentResource: this.ParentResource, - resourceType: this.ResourceType, - resourceName: this.ResourceName); - -#pragma warning restore 618 - } - /// /// Returns true if this is a resource get at any level. /// @@ -709,7 +554,7 @@ private bool IsResourceTypeCollectionGet() /// private bool IsSubscriptionLevelResourceTypeCollectionGet() { - return this.SubscriptionId.Length == 1 && + return this.SubscriptionId != Guid.Empty && this.ResourceGroupName == null && this.ResourceName == null && this.ExtensionResourceName == null && @@ -721,7 +566,7 @@ private bool IsSubscriptionLevelResourceTypeCollectionGet() /// private bool IsResourceGroupLevelResourceTypeCollectionGet() { - return this.SubscriptionId.Length == 1 && + return this.SubscriptionId != Guid.Empty && this.ResourceGroupName != null && this.ResourceName == null && this.ExtensionResourceName == null && @@ -734,7 +579,7 @@ private bool IsResourceGroupLevelResourceTypeCollectionGet() /// private bool IsTenantLevelResourceTypeCollectionGet() { - return this.SubscriptionId.Length == 0 && + return this.SubscriptionId == Guid.Empty && this.ResourceGroupName == null && this.ResourceName == null && this.ExtensionResourceName == null && @@ -747,10 +592,8 @@ private bool IsTenantLevelResourceTypeCollectionGet() /// private bool IsSubscriptionLevelResourceGet() { - return this.SubscriptionId.Length == 1 && + return this.SubscriptionId != Guid.Empty && this.ResourceGroupName == null && - this.TagName == null && - this.TagValue == null && (this.ResourceName != null || this.ExtensionResourceName != null) && (this.ResourceType != null || this.ExtensionResourceType != null); } @@ -761,10 +604,8 @@ private bool IsSubscriptionLevelResourceGet() /// private bool IsResourceGroupLevelResourceGet() { - return this.SubscriptionId.Length == 1 && + return this.SubscriptionId != Guid.Empty && this.ResourceGroupName != null && - this.TagName == null && - this.TagValue == null && (this.ResourceName != null || this.ExtensionResourceName != null) && (this.ResourceType != null || this.ExtensionResourceType != null); } @@ -774,10 +615,8 @@ private bool IsResourceGroupLevelResourceGet() /// private bool IsTenantLevelResourceGet() { - return this.SubscriptionId.Length == 0 && + return this.SubscriptionId == Guid.Empty && this.ResourceGroupName == null && - this.TagName == null && - this.TagValue == null && (this.ResourceName != null || this.ExtensionResourceName != null) && (this.ResourceType != null || this.ExtensionResourceType != null); } @@ -787,7 +626,7 @@ private bool IsTenantLevelResourceGet() /// private bool IsSubscriptionLevelQuery() { - return this.SubscriptionId.Length == 1 && + return this.SubscriptionId != Guid.Empty && this.ResourceGroupName == null; } @@ -796,11 +635,9 @@ private bool IsSubscriptionLevelQuery() /// private bool IsResourceGroupLevelQuery() { - return this.SubscriptionId.Length == 1 && + return this.SubscriptionId != Guid.Empty && this.ResourceGroupName != null && - (this.TagName != null || - this.TagValue != null || - this.ResourceName != null || + (this.ResourceName != null || this.ExtensionResourceName != null || this.ResourceType != null || this.ExtensionResourceType != null); diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/MoveAzureResourceCmdlet.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/MoveAzureResourceCmdlet.cs index 445e9d4a5158..9871a58adf67 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/MoveAzureResourceCmdlet.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/MoveAzureResourceCmdlet.cs @@ -59,12 +59,6 @@ public class MoveAzureResourceCommand : ResourceManagerCmdletBase [Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")] public SwitchParameter Force { get; set; } - /// - /// Gets or sets a value that indicates if the operation should wait for completion before returning the result. If set, the cmdlet will return as soon as the request is accepted. - /// - [Parameter(Mandatory = false, HelpMessage = "Do not wait for operation to complete.")] - public SwitchParameter NoWait { get; set; } - /// /// Gets or sets the ids of the resources to move. /// @@ -101,10 +95,6 @@ protected override void OnEndProcessing() /// private void RunCmdlet() { - if(this.NoWait.IsPresent) - { - this.WriteWarning("The NoWait parameter is obsolete and will be removed in future releases."); - } var resourceIdsToUse = this.resourceIds .Concat(this.ResourceId) .DistinctArray(StringComparer.InvariantCultureIgnoreCase); @@ -161,28 +151,21 @@ private void RunCmdlet() cancellationToken: this.CancellationToken.Value) .Result; - if(!this.NoWait) - { - var managementUri = this.GetResourcesClient() - .GetResourceManagementRequestUri( - resourceId: destinationResourceGroup, - apiVersion: apiVersion, - action: Constants.MoveResources); + var managementUri = this.GetResourcesClient() + .GetResourceManagementRequestUri( + resourceId: destinationResourceGroup, + apiVersion: apiVersion, + action: Constants.MoveResources); - var activity = string.Format("POST {0}", managementUri.PathAndQuery); + var activity = string.Format("POST {0}", managementUri.PathAndQuery); - var result = this - .GetLongRunningOperationTracker( - activityName: activity, - isResourceCreateOrUpdate: false) - .WaitOnOperation(operationResult: operationResult); + var result = this + .GetLongRunningOperationTracker( + activityName: activity, + isResourceCreateOrUpdate: false) + .WaitOnOperation(operationResult: operationResult); - this.TryConvertAndWriteObject(result, ResourceObjectFormat.New); - } - else - { - this.WriteObject(operationResult); - } + this.TryConvertAndWriteObject(result, ResourceObjectFormat.New); }); } } diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceLockManagementCmdletBase.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceLockManagementCmdletBase.cs index e0a72dc6bf71..7f84ad3b9e4c 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceLockManagementCmdletBase.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceLockManagementCmdletBase.cs @@ -88,16 +88,6 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa [ValidateNotNullOrEmpty] public string ResourceType { get; set; } - /// - /// Gets or sets the subscription id parameter. - /// - [Parameter(ParameterSetName = ResourceLockManagementCmdletBase.ResourceGroupResourceLevelLock, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = false, HelpMessage = "The subscription to use.")] - [Parameter(ParameterSetName = ResourceLockManagementCmdletBase.ResourceGroupLevelLock, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = false, HelpMessage = "The subscription to use.")] - [Parameter(ParameterSetName = ResourceLockManagementCmdletBase.SubscriptionLevelLock, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = false, HelpMessage = "The subscription to use.")] - [Parameter(ParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = false, HelpMessage = "The subscription to use.")] - [ValidateNotNullOrEmpty] - public Guid? SubscriptionId { get; set; } - /// /// Gets or sets the resource group name parameter. /// @@ -119,22 +109,6 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa [ValidateNotNullOrEmpty] public string LockId { get; set; } - /// - /// Initializes the default subscription id if needed. - /// - protected override void OnProcessRecord() - { - if (string.IsNullOrWhiteSpace(this.LockId) && - string.IsNullOrWhiteSpace(this.Scope) && - this.SubscriptionId == null && - !this.TenantLevel) - { - this.SubscriptionId = DefaultContext.Subscription.Id; - } - - base.OnProcessRecord(); - } - /// /// Gets the resource Id from the supplied PowerShell parameters. /// @@ -155,14 +129,14 @@ protected string GetResourceId(string lockName) throw new InvalidOperationException(string.Format("The Id '{0}' does not belong to a lock.", this.LockId)); } - + return !string.IsNullOrWhiteSpace(this.Scope) ? ResourceIdUtility.GetResourceId( resourceId: this.Scope, extensionResourceType: Constants.MicrosoftAuthorizationLocksType, extensionResourceName: lockName) : ResourceIdUtility.GetResourceId( - subscriptionId: this.SubscriptionId, + subscriptionId: this.DefaultContext.Subscription.Id, resourceGroupName: this.ResourceGroupName, resourceType: this.ResourceType, resourceName: this.ResourceName, diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManipulationCmdletBase.cs b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManipulationCmdletBase.cs index 97acf711f083..279b403c42af 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManipulationCmdletBase.cs +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceManipulationCmdletBase.cs @@ -63,13 +63,6 @@ public abstract class ResourceManipulationCmdletBase : ResourceManagerCmdletBase [ValidateNotNullOrEmpty] public string ResourceType { get; set; } - /// - /// Gets or sets the deprecated parent resource parameter. - /// - [Parameter(ParameterSetName = ResourceManipulationCmdletBase.SubscriptionLevelResoruceParameterSet, Mandatory = false, ValueFromPipelineByPropertyName = false, HelpMessage = "The parent resource type. e.g. Servers/myServer.")] - [ValidateNotNullOrEmpty] - public string ParentResource { get; set; } - /// /// Gets or sets the extension resource name parameter. /// @@ -93,13 +86,6 @@ public abstract class ResourceManipulationCmdletBase : ResourceManagerCmdletBase [ValidateNotNullOrEmpty] public string ODataQuery { get; set; } - /// - /// Gets or sets the subscription id parameter. - /// - [Parameter(ParameterSetName = ResourceManipulationCmdletBase.SubscriptionLevelResoruceParameterSet, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The subscription to use.")] - [ValidateNotNullOrEmpty] - public Guid? SubscriptionId { get; set; } - /// /// Gets or sets the resource group name parameter. /// @@ -119,24 +105,24 @@ public abstract class ResourceManipulationCmdletBase : ResourceManagerCmdletBase [Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")] public SwitchParameter Force { get; set; } + /// + /// Gets or sets the subscription id. + /// + public Guid SubscriptionId { get; set; } + /// /// Initializes the default subscription id if needed. /// - protected override void OnProcessRecord() + public ResourceManipulationCmdletBase() { - if(this.SubscriptionId != null) - { - this.WriteWarning("The SubscriptionId parameter is obsolete and will be removed in future releases."); - } - if (!string.IsNullOrEmpty(this.ParentResource)) - { - this.WriteWarning("The ParentResource parameter is obsolete and will be removed in future releases. Please use the -ResourceType and -ResourceName parameters instead."); - } - if (string.IsNullOrWhiteSpace(this.ResourceId) && !this.TenantLevel && this.SubscriptionId == null) + if (string.IsNullOrEmpty(this.ResourceId)) { this.SubscriptionId = DefaultContext.Subscription.Id; } + } + protected override void OnProcessRecord() + { base.OnProcessRecord(); } @@ -149,9 +135,7 @@ protected string GetResourceId() return !string.IsNullOrWhiteSpace(this.ResourceId) ? this.ResourceId - : !this.TenantLevel || string.IsNullOrWhiteSpace(this.ParentResource) - ? this.GetResourceIdWithoutParentResource() - : this.GetResourceIdWithParentResource(); + : this.GetResourceIdWithoutParentResource(); #pragma warning restore 618 } @@ -169,22 +153,5 @@ private string GetResourceIdWithoutParentResource() extensionResourceType: this.ExtensionResourceType, extensionResourceName: this.ExtensionResourceName); } - - /// - /// Gets the resource Id using the ParentResource. - /// - private string GetResourceIdWithParentResource() - { -#pragma warning disable 618 - - return ResourceIdUtility.GetResourceId( - subscriptionId: this.SubscriptionId.Value, - resourceGroupName: this.ResourceGroupName, - parentResource: this.ParentResource, - resourceType: this.ResourceType, - resourceName: this.ResourceName); - -#pragma warning restore 618 - } } } \ No newline at end of file diff --git a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Microsoft.Azure.Commands.ResourceManager.Cmdlets.dll-Help.xml b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Microsoft.Azure.Commands.ResourceManager.Cmdlets.dll-Help.xml index b4d613db7b4e..c7de93f98193 100644 --- a/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Microsoft.Azure.Commands.ResourceManager.Cmdlets.dll-Help.xml +++ b/src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Microsoft.Azure.Commands.ResourceManager.Cmdlets.dll-Help.xml @@ -1396,13 +1396,6 @@ String - - SubscriptionId - - - - Nullable`1[Guid] - ResourceGroupName @@ -1601,13 +1594,6 @@ String - - SubscriptionId - - - - Nullable`1[Guid] - ApiVersion @@ -1660,13 +1646,6 @@ String - - SubscriptionId - - - - Nullable`1[Guid] - ResourceGroupName @@ -3299,13 +3278,6 @@ String - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - ResourceGroupName @@ -3494,13 +3466,6 @@ String - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - ApiVersion @@ -3581,13 +3546,6 @@ String - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - ResourceGroupName @@ -4631,13 +4589,6 @@ String - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - ResourceGroupName @@ -6111,13 +6062,6 @@ String - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - ResourceGroupName @@ -6306,13 +6250,6 @@ String - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - ApiVersion @@ -6393,13 +6330,6 @@ String - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - ResourceGroupName @@ -6627,18 +6557,6 @@ - - SubscriptionId - - The subscription to use. - - Nullable`1[Guid] - - Nullable`1[Guid] - - - - ResourceGroupName diff --git a/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 b/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 index b5e603879492..42b855dcd71d 100644 --- a/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 +++ b/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 @@ -67,16 +67,16 @@ FormatsToProcess = @( '.\AzureRM.Profile\Microsoft.Azure.Commands.Profile.format.ps1xml', '.\AzureRM.DataFactories\Microsoft.Azure.Commands.DataFactories.format.ps1xml', '.\AzureRM.RedisCache\Microsoft.Azure.Commands.RedisCache.format.ps1xml', - '.\AzureRM.AzureBatch\Microsoft.Azure.Commands.Batch.format.ps1xml', + '.\AzureRM.Batch\Microsoft.Azure.Commands.Batch.format.ps1xml', '.\AzureRM.KeyVault\Microsoft.Azure.Commands.KeyVault.format.ps1xml', '.\AzureRM.StreamAnalytics\Microsoft.Azure.Commands.StreamAnalytics.format.ps1xml', '.\AzureRM.Compute\Microsoft.Azure.Commands.Compute.format.ps1xml', '.\AzureRM.Compute\Microsoft.Azure.Commands.Compute.format.generated.ps1xml', '.\AzureRM.Network\Microsoft.Azure.Commands.Network.format.ps1xml', '.\Azure.Storage\Microsoft.WindowsAzure.Commands.Storage.format.ps1xml', - '.\AzureRM.StorageManagement\Microsoft.Azure.Commands.Management.Storage.format.ps1xml', + '.\AzureRM.Storage\Microsoft.Azure.Commands.Management.Storage.format.ps1xml', '.\AzureRM.OperationalInsights\Microsoft.Azure.Commands.OperationalInsights.format.ps1xml', - '.\AzureRM.AzureBackup\Microsoft.Azure.Commands.AzureBackup.format.ps1xml', + '.\AzureRM.Backup\Microsoft.Azure.Commands.AzureBackup.format.ps1xml', '.\AzureRM.UsageAggregates\Microsoft.Azure.Commands.UsageAggregates.Format.ps1xml', '.\AzureRM.Sql\Microsoft.Azure.Commands.Sql.format.ps1xml' ) @@ -91,7 +91,7 @@ NestedModules = @( '.\AzureRM.Sql\Microsoft.Azure.Commands.Sql.dll', '.\AzureRM.DataFactories\Microsoft.Azure.Commands.DataFactories.dll', '.\AzureRM.RedisCache\Microsoft.Azure.Commands.RedisCache.dll', - '.\AzureRM.AzureBatch\Microsoft.Azure.Commands.Batch.dll', + '.\AzureRM.Batch\Microsoft.Azure.Commands.Batch.dll', '.\AzureRM.Dns\Microsoft.Azure.Commands.Dns.dll', '.\AzureRM.KeyVault\Microsoft.Azure.Commands.KeyVault.dll', '.\AzureRM.TrafficManager\Microsoft.Azure.Commands.TrafficManager.dll', @@ -102,12 +102,12 @@ NestedModules = @( '.\AzureRM.Network\Microsoft.Azure.Commands.Network.dll', '.\Azure.Storage\Microsoft.WindowsAzure.Commands.Storage.dll', '.\AzureRM.ApiManagement\Microsoft.Azure.Commands.ApiManagement.dll', - '.\AzureRM.StorageManagement\Microsoft.Azure.Commands.Management.Storage.dll', + '.\AzureRM.Storage\Microsoft.Azure.Commands.Management.Storage.dll', '.\AzureRM.OperationalInsights\Microsoft.Azure.Commands.OperationalInsights.dll', '.\AzureRM.UsageAggregates\Microsoft.Azure.Commands.UsageAggregates.dll', '.\AzureRM.HDInsight\Microsoft.Azure.Commands.HDInsight.dll', '.\AzureRM.ApiManagement\Microsoft.Azure.Commands.ApiManagement.ServiceManagement.dll', - '.\AzureRM.AzureBackup\Microsoft.Azure.Commands.AzureBackup.dll', + '.\AzureRM.Backup\Microsoft.Azure.Commands.AzureBackup.dll', '.\AzureRM.SiteRecovery\Microsoft.Azure.Commands.SiteRecovery.dll' ) diff --git a/src/ResourceManager/Storage/AzureRM.Storage.psd1 b/src/ResourceManager/Storage/AzureRM.Storage.psd1 index e50c9e9505b5..87be3fc8d155 100644 --- a/src/ResourceManager/Storage/AzureRM.Storage.psd1 +++ b/src/ResourceManager/Storage/AzureRM.Storage.psd1 @@ -46,8 +46,8 @@ ProcessorArchitecture = 'None' # Modules that must be imported into the global environment prior to importing this module RequiredModules = @( - @{ ModuleName = 'AzureRM.Profile'; ModuleVersion = '0.9.8' }, - @{ ModuleName = 'Azure.Storage'; ModuleVersion = '0.9.8' } + @{ ModuleName = 'AzureRM.Profile'; ModuleVersion = '0.9.8' }, + @{ ModuleName = 'Azure.Storage'; ModuleVersion = '0.9.8' } ) # Assemblies that must be loaded prior to importing this module @@ -61,7 +61,7 @@ TypesToProcess = @() # Format files (.ps1xml) to be loaded when importing this module FormatsToProcess = @( - '.\Microsoft.Azure.Commands.Management.Storage.format.ps1xml', + '.\Microsoft.Azure.Commands.Management.Storage.format.ps1xml' ) # Modules to import as nested modules of the module specified in ModuleToProcess diff --git a/src/ResourceManager/Storage/Commands.Management.Storage/Commands.Management.Storage.csproj b/src/ResourceManager/Storage/Commands.Management.Storage/Commands.Management.Storage.csproj index 87df71b19da9..bb17d972b332 100644 --- a/src/ResourceManager/Storage/Commands.Management.Storage/Commands.Management.Storage.csproj +++ b/src/ResourceManager/Storage/Commands.Management.Storage/Commands.Management.Storage.csproj @@ -19,7 +19,7 @@ true full false - ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.StorageManagement\ + ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Storage\ DEBUG;TRACE prompt 4 @@ -31,7 +31,7 @@ pdbonly TRACE;SIGN true - ..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.StorageManagement\ + ..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Storage\ TRACE bin\Release\Microsoft.Azure.Commands.Management.Storage.dll.CodeAnalysisLog.xml true diff --git a/tools/Installer/generate.ps1 b/tools/Installer/generate.ps1 index 3422d4d6c5b6..eef23adce6f5 100644 --- a/tools/Installer/generate.ps1 +++ b/tools/Installer/generate.ps1 @@ -1,3 +1,17 @@ +# ---------------------------------------------------------------------------------- +# +# 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. +# ---------------------------------------------------------------------------------- + param( [Parameter(Mandatory = $false, Position = 0)] [string] $buildConfig diff --git a/tools/PublishModules.ps1 b/tools/PublishModules.ps1 new file mode 100644 index 000000000000..5a80b036a65c --- /dev/null +++ b/tools/PublishModules.ps1 @@ -0,0 +1,69 @@ +# ---------------------------------------------------------------------------------- +# +# 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. +# ---------------------------------------------------------------------------------- + +param( + [Parameter(Mandatory = $false, Position = 0)] + [string] $buildConfig, + [Parameter(Mandatory = $false, Position = 1)] + [string] $apiKey, + [Parameter(Mandatory = $false, Position = 2)] + [string] $repositoryLocation +) + +if ([string]::IsNullOrEmpty($buildConfig)) +{ + Write-Verbose "Setting build configuration to 'Release'" + $buildConfig = 'Release' +} + +if ([string]::IsNullOrEmpty($repositoryLocation)) +{ + Write-Verbose "Setting repository location to 'http://psget/PSGallery/api/v2/'" + $repositoryLocation = 'http://psget/PSGallery/api/v2/' +} + +$packageFolder = "$PSScriptRoot\..\src\Package" +$scriptFolder = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent +. ($scriptFolder + '.\SetupEnv.ps1') + +if (Test-Path $packageFolder) { + Remove-Item -Path $packageFolder -Recurse -Force +} + +# Build the cmdlets in debug mode +msbuild "$env:AzurePSRoot\build.proj" /t:"BuildDebug" + +$repoName = $(New-Guid).ToString() +Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation -InstallationPolicy Trusted +$modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure" +# Publish Azure module +Write-Host "Publishing Azure module from $modulePath" +Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName +Write-Host "Published Azure module" +# Publish AzureRM.Profile module +Write-Host "Publishing AzureRM.Profile module from $modulePath" +Publish-Module -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager\AzureRM.Profile" -NuGetApiKey $apiKey -Repository $repoName +Write-Host "Published AzureRM.Profile module" + +# Publish AzureRM modules +$resourceManagerModules = Get-ChildItem -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager" -Directory +foreach ($module in $resourceManagerModules) { + if ($module -ne "AzureRM.Profile") { + $modulePath = $module.FullName + Write-Host "Publishing $module module from $modulePath" + Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName + Write-Host "Published $module module" + } +} +Unregister-PSRepository -Name $repoName \ No newline at end of file