Skip to content

Commit fa09303

Browse files
committed
Merge branch 'preview' of github.com:/azure/azure-powershell into nsoft9merge
2 parents 676d7e3 + 0f781b0 commit fa09303

File tree

11 files changed

+105
-32
lines changed

11 files changed

+105
-32
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
In the new Az Netstandard module, the default prefix for all cmdlets is "Az". However, in order to prevent massive breaking changes that require scripts to be immediately rewritten, we have created a new cmdlet "Enable-AzureRmAlias" that will enable aliases to the old "AzureRm" prefix. This is a guide on how to add aliases for new cmdlets added to any module.
2+
3+
1.) Ensure your cmdlet attribute is formatted correctly to include the AzureRMPrefix. This will make the cmdlet prefix "Az" for Netstandard and "AzureRM" for the legacy desktop module (while the desktop module continues to be maintained). Example can be found [here](https://github.com/Azure/azure-powershell/blob/preview/src/ResourceManager/Profile/Commands.Profile/Default/GetAzureRmDefault.cs#L29).
4+
5+
2.) Ensure both AzureRm.\<moduleName>.psd1 and Az.\<moduleName>.psd1 are updated with all new cmdlets. The prefix for cmdlets in AzureRM.\<moduleName>.psd1 should be AzureRm, and the prefix for cmdlets in Az.\<moduleName>.psd1 should be Az.
6+
7+
3.) Run the script to create alias mapping. This can be found in [tools/CreateAliasMappings.ps1](https://github.com/Azure/azure-powershell/blob/preview/tools/CreateAliasMapping.ps1).
8+
9+
4.) Copy the output contents from [tools/AliasMappings.json](https://github.com/Azure/azure-powershell/blob/preview/tools/AliasMapping.json) into the mapping variable in [src/ResourceManager/Profile/Commands.Profile/AzureRmAlias/Mappings.cs](https://github.com/Azure/azure-powershell/blob/preview/src/ResourceManager/Profile/Commands.Profile/AzureRmAlias/Mappings.cs#L36).

src/ResourceManager/Compute/Commands.Compute/help/Export-AzureRmLogAnalyticRequestRateByInterval.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ Export-AzureRmLogAnalyticRequestRateByInterval [-FromTime] <DateTime> [-GroupByO
2020
```
2121

2222
## DESCRIPTION
23-
This exports aggregated numbers of Microsoft.Compute API calls separated by Success, Failure, or Throttled displayed in time intervals.
24-
The logs can be further grouped by three parameters: GroupByOperationName, GroupByThrottlePolicy, or GroupByResourceName.
25-
Note that this cmdlet collects only CRP logs.
23+
Exports statistical data about the subscription's calls to the Microsoft.Compute API by Success, Failure, or Throttled status, in predefined time intervals. The logs can be further grouped by three parameters: GroupByOperationName, GroupByThrottlePolicy, or GroupByResourceName.
24+
Note that this cmdlet collects only Compute Resource Provider logs; moreover, data about the Disk and Snapshot resource types is not yet available.
25+
26+
For an overview of the Compute Resource Provider's API throttling, see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits.
2627

2728
## EXAMPLES
2829

src/ResourceManager/Compute/Commands.Compute/help/Export-AzureRmLogAnalyticThrottledRequests.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This exports the total number of throttled Microsoft.Compute API calls.
2424
The logs can be further aggregated by three options: GroupByOperationName, GroupByThrottlePolicy, or GroupByResourceName.
2525
Note that this cmdlet collects only CRP logs.
2626

27+
For an overview of the Compute Resource Provider's API throttling, see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits.
28+
2729
## EXAMPLES
2830

2931
### Example 1

src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/SetDiagnosticSettingCommandTests.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,23 @@ public void SetSomeCategories()
203203
expectedSettings.Logs[0].Enabled = false;
204204

205205
VerifyCalledOnce();
206-
VerifySettings(expectedSettings, this.calledSettings);
206+
VerifySettings(expectedSettings, this.calledSettings, suffix: "#1");
207207

208208
// Testing the new categories must be known before the cmdlet can add them
209+
expectedSettings.Logs.Add(
210+
new LogSettings()
211+
{
212+
Category = "TestCategory3",
213+
RetentionPolicy = new RetentionPolicy
214+
{
215+
Days = 0,
216+
Enabled = false
217+
}
218+
});
209219
cmdlet.Categories = new List<string> { "TestCategory3" };
210220
cmdlet.Enabled = false;
211221
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
212-
var argException = Assert.Throws<PSInvalidOperationException>(() => cmdlet.ExecuteCmdlet());
213-
Assert.Contains("ArgumentException", argException.ToString());
222+
cmdlet.ExecuteCmdlet();
214223

215224
// Testing the new metric categories must be known before the cmdlet can add them
216225
expectedSettings.Metrics[0].Enabled = false;
@@ -220,14 +229,13 @@ public void SetSomeCategories()
220229
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
221230
cmdlet.ExecuteCmdlet();
222231

223-
VerifySettings(expectedSettings, this.calledSettings);
232+
VerifySettings(expectedSettings, this.calledSettings, suffix: "#2");
224233

225234
// Testing the new categories must be known before the cmdlet can add them
226235
cmdlet.MetricCategory = new List<string> { "MetricCat3" };
227236
cmdlet.Enabled = false;
228237
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
229-
argException = Assert.Throws<PSInvalidOperationException>(() => cmdlet.ExecuteCmdlet());
230-
Assert.Contains("ArgumentException", argException.ToString());
238+
cmdlet.ExecuteCmdlet();
231239
}
232240

233241
[Fact]
@@ -310,7 +318,8 @@ private void VerifyCalledOnce()
310318

311319
private void VerifySettings(
312320
DiagnosticSettingsResource expectedSettings,
313-
DiagnosticSettingsResource actualSettings)
321+
DiagnosticSettingsResource actualSettings,
322+
string suffix = "")
314323
{
315324
Assert.Equal(expectedSettings.StorageAccountId, actualSettings.StorageAccountId);
316325
Assert.Equal(expectedSettings.EventHubName, actualSettings.EventHubName);
@@ -321,7 +330,7 @@ private void VerifySettings(
321330
}
322331
else
323332
{
324-
Assert.True(expectedSettings.Logs.Count == actualSettings.Logs.Count, string.Format("Expected: {0}, Actual: {1}, no the same number of Log settings", expectedSettings.Logs.Count, actualSettings.Logs.Count));
333+
Assert.True(expectedSettings.Logs.Count == actualSettings.Logs.Count, string.Format("Expected: {0}, Actual: {1}, no the same number of Log settings {2}", expectedSettings.Logs.Count, actualSettings.Logs.Count, suffix));
325334
for (int i = 0; i < expectedSettings.Logs.Count; i++)
326335
{
327336
var expected = expectedSettings.Logs[i];
@@ -338,7 +347,7 @@ private void VerifySettings(
338347
}
339348
else
340349
{
341-
Assert.True(expectedSettings.Metrics.Count == actualSettings.Metrics.Count, string.Format("Expected: {0}, Actual: {1}, no the same number of Metric settings", expectedSettings.Metrics.Count, actualSettings.Metrics.Count));
350+
Assert.True(expectedSettings.Metrics.Count == actualSettings.Metrics.Count, string.Format("Expected: {0}, Actual: {1}, no the same number of Metric settings {2}", expectedSettings.Metrics.Count, actualSettings.Metrics.Count, suffix));
342351
for (int i = 0; i < expectedSettings.Metrics.Count; i++)
343352
{
344353
var expected = expectedSettings.Metrics[i];

src/ResourceManager/Insights/Commands.Insights/ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
-->
2020
## Current Release
2121

22+
* Fixed issues #6833 and #7102 (Diagnostic Settings area)
23+
- Issues with the default name, i.e. "service", during creation and listing/getting of diagnostic settings
24+
- Issues creating diagnostic settings with categories
25+
26+
* Added deprecation message for metrics time grains parameters
27+
- Timegrains parameters are still being accepted (this is a non-breaking change,) but they are ignored in the backend since only PT1M is valid
28+
2229
## Version 5.1.3
2330
* Fixed issue with default resource groups not being set.
2431
* Updated common runtime assemblies

src/ResourceManager/Insights/Commands.Insights/Diagnostics/SetAzureRmDiagnosticSettingCommand.cs

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,13 @@ private void SetSelectedTimegrains(DiagnosticSettingsResource properties)
364364
throw new ArgumentException("Parameter 'Enabled' is required by 'Timegrains' parameter.");
365365
}
366366

367-
if (this.Timegrains.Count > 0)
367+
if (this.Timegrains != null && this.Timegrains.Count > 0)
368368
{
369+
if (properties.Metrics == null)
370+
{
371+
properties.Metrics = new List<MetricSettings>();
372+
}
373+
369374
WriteWarningWithTimestamp("Deprecation: The timegain argument for metrics will be deprecated since the back end supports only PT1M. Currently it is ignored for backwards compatibility.");
370375
WriteDebugWithTimestamp("Setting Enabled property for metrics since timegrains argument is non-empty");
371376
foreach (MetricSettings metric in properties.Metrics)
@@ -383,16 +388,35 @@ private void SetSelectedCategories(DiagnosticSettingsResource properties)
383388
}
384389

385390
WriteDebugWithTimestamp("Setting log categories, including Enabled property");
391+
if (properties.Logs == null)
392+
{
393+
properties.Logs = new List<LogSettings>();
394+
}
395+
386396
foreach (string category in this.Categories)
387397
{
388398
LogSettings logSettings = properties.Logs.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));
389-
390399
if (logSettings == null)
391400
{
392-
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Log category '{0}' is not available", category));
393-
}
401+
// if not there add it
402+
logSettings = new LogSettings()
403+
{
404+
Category = category,
405+
RetentionPolicy = new RetentionPolicy
406+
{
407+
Days = 0,
408+
Enabled = false
409+
},
410+
Enabled = this.Enabled
411+
};
394412

395-
logSettings.Enabled = this.Enabled;
413+
properties.Logs.Add(logSettings);
414+
}
415+
else
416+
{
417+
// else update it
418+
logSettings.Enabled = this.Enabled;
419+
}
396420
}
397421
}
398422

@@ -404,16 +428,37 @@ private void SetSelectedMetricsCategories(DiagnosticSettingsResource properties)
404428
}
405429

406430
WriteDebugWithTimestamp("Setting metric categories, including Enabled property");
431+
if (properties.Metrics == null)
432+
{
433+
properties.Metrics = new List<MetricSettings>();
434+
}
435+
407436
foreach (string category in this.MetricCategory)
408437
{
409438
MetricSettings metricSettings = properties.Metrics.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));
410439

411440
if (metricSettings == null)
412441
{
413-
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Metric category '{0}' is not available", category));
414-
}
442+
// If not there add it
443+
metricSettings = new MetricSettings
444+
{
445+
Category = category,
446+
Enabled = this.Enabled,
447+
RetentionPolicy = new RetentionPolicy
448+
{
449+
Days = 0,
450+
Enabled = false
451+
},
452+
TimeGrain = null
453+
};
415454

416-
metricSettings.Enabled = this.Enabled;
455+
properties.Metrics.Add(metricSettings);
456+
}
457+
else
458+
{
459+
// else update it
460+
metricSettings.Enabled = this.Enabled;
461+
}
417462
}
418463
}
419464

@@ -425,12 +470,22 @@ private void SetAllCategoriesAndTimegrains(DiagnosticSettingsResource properties
425470
}
426471

427472
WriteDebugWithTimestamp("Setting Enabled property for logs");
473+
if (properties.Logs == null)
474+
{
475+
properties.Logs = new List<LogSettings>();
476+
}
477+
428478
foreach (var log in properties.Logs)
429479
{
430480
log.Enabled = this.Enabled;
431481
}
432482

433483
WriteDebugWithTimestamp("Setting Enabled property for metrics");
484+
if (properties.Metrics == null)
485+
{
486+
properties.Metrics = new List<MetricSettings>();
487+
}
488+
434489
foreach (var metric in properties.Metrics)
435490
{
436491
metric.Enabled = this.Enabled;
@@ -470,7 +525,6 @@ private void SetEventHubRule(DiagnosticSettingsResource properties)
470525
}
471526
}
472527

473-
474528
private void SetStorage(DiagnosticSettingsResource properties)
475529
{
476530
if (this.isStorageParamPresent)

src/ResourceManager/Websites/Commands.Websites/help/Set-AzureRmWebAppSlotConfigName.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The **Set-AzureRmWebAppSlotConfigName** cmdlet marks App Settings and Connection
3434

3535
### 1:
3636
```
37-
PS C:\> Set-AzureRmWebAppSlotConfigName -ResourceGroupName "Default-Web-WestUS" -Name "ContosoWebApp" -Slot "Slot001" -RemoveAllAppSettingNames -RemoveAllConnectionStringNames
37+
PS C:\> Set-AzureRmWebAppSlotConfigName -ResourceGroupName "Default-Web-WestUS" -Name "ContosoWebApp" -RemoveAllAppSettingNames -RemoveAllConnectionStringNames
3838
```
3939

4040
This command removes all app settings and connection strings for Web App ContosoWebApp associated with the resource group Default-Web-WestUS

src/Storage/Commands.Storage/Azure.Storage.psd1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ CmdletsToExport = 'Get-AzureStorageTable', 'New-AzureStorageTableSASToken',
126126
'Stop-AzureStorageBlobCopy', 'Update-AzureStorageServiceProperty',
127127
'Get-AzureStorageServiceProperty',
128128
'Enable-AzureStorageDeleteRetentionPolicy',
129-
'Disable-AzureStorageDeleteRetentionPolicy',
130-
'Enable-AzureStorageStaticWebsite',
131-
'Disable-AzureStorageStaticWebsite'
129+
'Disable-AzureStorageDeleteRetentionPolicy'
132130

133131
# Variables to export from this module
134132
# VariablesToExport = @()

src/Storage/Commands.Storage/ChangeLog.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
* Upgrade to Azure Storage Client Library 9.3.0 and Azure Storage DataMovement Library 0.8.1
2222
* Support create Storage Context with OAuth.
2323
- New-AzureStorageContext
24-
* Support Static Website configuration
25-
- Enable-AzureStorageStaticWebsite
26-
- Disable-AzureStorageStaticWebsite
2724

2825
## Version 4.5.0
2926
* Remove the 5TB limitation for Azure File Share quota

src/Storage/Commands.Storage/Common/Cmdlet/DisableAzureStorageStaticWebsite.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2323
/// <summary>
2424
/// Disable azure storage service StaticWebsite, currently only available on Blob service
2525
/// </summary>
26-
[Cmdlet(VerbsLifecycle.Disable, Azure.Commands.ResourceManager.Common.AzureRMConstants.AzurePrefix + "StorageStaticWebsite", SupportsShouldProcess = true),
27-
OutputType(typeof(PSStaticWebsiteProperties))]
2826
public class DisableAzureStorageServiceStaticWebsiteCommand : StorageCloudBlobCmdletBase
2927
{
3028
[Parameter(Mandatory = false)]

src/Storage/Commands.Storage/Common/Cmdlet/EnableAzureStorageStaticWebsite.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2323
/// <summary>
2424
/// Enable azure storage service StaticWebsite, currently only enabled on Blob service
2525
/// </summary>
26-
[Cmdlet(VerbsLifecycle.Enable, Azure.Commands.ResourceManager.Common.AzureRMConstants.AzurePrefix + "StorageStaticWebsite", SupportsShouldProcess = true),
27-
OutputType(typeof(PSStaticWebsiteProperties))]
2826
public class EnableAzureStorageServiceStaticWebsiteCommand : StorageCloudBlobCmdletBase
2927
{
3028
[Parameter(Mandatory = true, Position = 0, HelpMessage = "The name of the index document in each directory.")]

0 commit comments

Comments
 (0)