Skip to content

Commit 8cbee16

Browse files
committed
Changing alias infrastructure for sql aliases
1 parent 117634e commit 8cbee16

File tree

8 files changed

+87
-55
lines changed

8 files changed

+87
-55
lines changed

setup/azurecmdfiles.wxi

Lines changed: 35 additions & 31 deletions
Large diffs are not rendered by default.

src/ResourceManager/Automation/Commands.Automation.Test/Commands.ResourceManagement.Automation.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ProductVersion>
77
</ProductVersion>
88
<SchemaVersion>2.0</SchemaVersion>
9-
<ProjectGuid>{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}</ProjectGuid>
9+
<ProjectGuid>{59D1B5DC-9175-43EC-90C6-CBA601B3565F}</ProjectGuid>
1010
<OutputType>Library</OutputType>
1111
<AppDesignerFolder>Properties</AppDesignerFolder>
1212
<RootNamespace>Microsoft.Azure.Commands.Automation.Test</RootNamespace>

src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ ProcessorArchitecture = 'None'
4747
# Modules that must be imported into the global environment prior to importing this module
4848
RequiredModules = @()
4949

50-
# Module definitions that will be imported prior. This line was added to make Aliases in NestedModules work.
51-
ModuleToProcess = 'AzureResourceManager.psm1'
52-
5350
# Assemblies that must be loaded prior to importing this module
5451
RequiredAssemblies = @()
5552

src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psm1

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@
257257
<Content Include="AzureResourceManager.psd1">
258258
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
259259
</Content>
260-
<Content Include="AzureResourceManager.psm1">
260+
<None Include="ResourceManagerStartup.ps1">
261261
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
262-
</Content>
262+
</None>
263263
<None Include="MSSharedLibKey.snk" />
264264
<None Include="packages.config" />
265265
<None Include="PostBuild.ps1" />

src/ResourceManager/Resources/Commands.Resources/PostBuild.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if (Test-Path -Path $sourcePath) {
3030
Remove-Item -Path $sourcePath -Force;
3131
}
3232

33-
$sourcePath = $sourceDir + "AzureResourceManager.psm1"
33+
$sourcePath = $sourceDir + "ResourceManagerStartup.ps1"
3434
$destDir = Split-Path -Path $sourceDir
3535

3636
if (Test-Path -Path $sourcePath) {

src/ResourceManager/Resources/Commands.Resources/ResourceGroups/GetAzureLocationCommand.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,42 @@
1414

1515
using System.Collections.Generic;
1616
using System.Management.Automation;
17+
using System.Reflection;
1718
using Microsoft.Azure.Commands.Resources.Models;
19+
using System.IO;
20+
using Microsoft.Azure.Common.Authentication;
1821

1922
namespace Microsoft.Azure.Commands.Resources
2023
{
2124
/// <summary>
2225
/// Get the available locations for certain resource types.
2326
/// </summary>
2427
[Cmdlet(VerbsCommon.Get, "AzureLocation"), OutputType(typeof(List<PSResourceProviderLocationInfo>))]
25-
public class GetAzureLocationCommand : ResourcesBaseCmdlet
28+
public class GetAzureLocationCommand : ResourcesBaseCmdlet, IModuleAssemblyInitializer
2629
{
2730
public override void ExecuteCmdlet()
2831
{
2932
WriteObject(ResourcesClient.GetLocations(), true);
3033
}
34+
35+
/// <summary>
36+
/// Load global aliases for ARM
37+
/// </summary>
38+
public void OnImport()
39+
{
40+
try
41+
{
42+
System.Management.Automation.PowerShell invoker = null;
43+
invoker = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
44+
invoker.AddScript(File.ReadAllText(FileUtilities.GetContentFilePath(
45+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
46+
"ResourceManagerStartup.ps1")));
47+
invoker.Invoke();
48+
}
49+
catch
50+
{
51+
// This will throw exception for tests, ignore.
52+
}
53+
}
3154
}
3255
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
$aliases = @{
17+
# Sql aliases
18+
"Get-AzureSqlDatabaseServerAuditingPolicy"="Get-AzureSqlServerAuditingPolicy";
19+
"Remove-AzureSqlDatabaseServerAuditing"="Remove-AzureSqlServerAuditing";
20+
"Set-AzureSqlDatabaseServerAuditingPolicy"="Set-AzureSqlServerAuditingPolicy";
21+
"Use-AzureSqlDatabaseServerAuditingPolicy"="Use-AzureSqlServerAuditingPolicy";
22+
}
23+
24+
$aliases.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"

0 commit comments

Comments
 (0)