Skip to content

Commit 8322fd2

Browse files
author
Haitao Chen
committed
add Startup script as well
1 parent e1015a7 commit 8322fd2

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,9 @@
19161916
<Component Id="cmp17459EC3296F82D03FEF8C426C8DA7EA" Guid="*">
19171917
<File Id="filF30732FD3174ABEC7D2103467F25E8E5" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.OperationalInsights\AzureRM.OperationalInsights.psd1" />
19181918
</Component>
1919+
<Component Id="cmpC77B4F6D332144EDAE5C8E2997F313F1" Guid="*">
1920+
<File Id="filD2FB04719F134FB9BF2BC1EE41908381" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.OperationalInsights\OperationalInsightsStartup.ps1" />
1921+
</Component>
19191922
<Component Id="cmp7CE9821E11931CE1140ACA06CF2D38B4" Guid="*">
19201923
<File Id="filD490745C6F4007A53448F93D7655F3D4" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.OperationalInsights\Hyak.Common.dll" />
19211924
</Component>
@@ -6071,6 +6074,7 @@
60716074
<ComponentRef Id="cmp275E5D23204FF3DB5A484691FFA2C6F5" />
60726075
<ComponentRef Id="cmp5E9A44B7330C75772463CB17D6D24AA6" />
60736076
<ComponentRef Id="cmp17459EC3296F82D03FEF8C426C8DA7EA" />
6077+
<ComponentRef Id="cmpC77B4F6D332144EDAE5C8E2997F313F1" />
60746078
<ComponentRef Id="cmp7CE9821E11931CE1140ACA06CF2D38B4" />
60756079
<ComponentRef Id="cmp6D68CAF3787D43356F3C2CB592699D2D" />
60766080
<ComponentRef Id="cmp20FBC1203D91D529F69E519C9C2F78B8" />

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/DataSourceTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ function Test-DataSourceCreateUpdateDelete
4848
Assert-AreEqual $subId1 $dataSource.Properties.SubscriptionId
4949
Assert-AreEqual "AzureActivityLog" $dataSource.Kind
5050

51-
# Create a second data source for list testing
51+
# Create a second data source for list testing, also cover the alias.
5252
$daNametwo = Get-ResourceName
53-
$dataSource = New-AzureRmOperationalInsightsAzureActivityLogDataSource -Workspace $workspace -Name $daNametwo -SubscriptionId $subId2
53+
$dataSource = New-AzureRmOperationalInsightsAzureAuditDataSource -Workspace $workspace -Name $daNametwo -SubscriptionId $subId2
5454

5555
# List the data source in the workspace (both param sets)
5656
$dataSources = Get-AzureRmOperationalInsightsDataSource -Workspace $workspace -Kind AzureActivityLog

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Commands.OperationalInsights.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@
235235
<SubType>Designer</SubType>
236236
</Content>
237237
<None Include="MSSharedLibKey.snk" />
238+
<Content Include="OperationalInsightsStartup.ps1">
239+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
240+
</Content>
238241
<None Include="packages.config">
239242
<SubType>Designer</SubType>
240243
</None>

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/DataSources/NewDataSourceCmdletsPerKind/NewAzureOperationalInsightsAzureActivityLogDataSourceCommand.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Authentication;
1516
using Microsoft.Azure.Commands.OperationalInsights.Models;
1617
using Microsoft.Azure.Commands.OperationalInsights.Properties;
18+
1719
using System;
20+
using System.IO;
1821
using System.Linq;
22+
using System.Reflection;
1923
using System.Management.Automation;
2024

2125
namespace Microsoft.Azure.Commands.OperationalInsights
@@ -68,5 +72,27 @@ public override void ExecuteCmdlet()
6872

6973
CreatePSDataSourceWithProperties(auditLogProperties);
7074
}
75+
76+
77+
/// <summary>
78+
/// Load global aliases for ARM
79+
/// </summary>
80+
public void OnImport()
81+
{
82+
try
83+
{
84+
System.Management.Automation.PowerShell invoker = null;
85+
invoker = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
86+
invoker.AddScript(File.ReadAllText(FileUtilities.GetContentFilePath(
87+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
88+
"OperationalInsightsStartup.ps1")));
89+
invoker.Invoke();
90+
}
91+
catch
92+
{
93+
// This will throw exception for tests, ignore.
94+
}
95+
96+
}
7197
}
7298
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
@{
16+
"New-AzureRmOperationalInsightsAzureAuditDataSource" = "New-AzureRmOperationalInsightsAzureActivityLogDataSource";
17+
}.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"

0 commit comments

Comments
 (0)