Skip to content

Release #1741

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 12 commits into from
Jan 29, 2016
Merged

Release #1741

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
4 changes: 3 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 2016.02.02 version 1.2.0
## 2016.02.02 version 1.2.0
* Azure RemoteApp: Organizational Unit in Azure RemoteApp RDFE cmdlets now accepts Unicode characters.
* Azure Stack Admin: New module for the management of azure stack administrative resources such as plan, offer, subscription, resource provider and gallery items
* Azure Stack Storage Admin: New module for the management of azure stack storage administrative resources such as configuration, infrastructure and health

## 2016.01.12 version 1.1.0
* Azure SQL Database: Threat Detection policies:
Expand Down
192 changes: 192 additions & 0 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions src/ResourceManager/AzureStackAdmin/AzureRM.AzureStackAdmin.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#
# Module manifest for module 'AzureRM.AzureStackAdmin'
#
# Generated by: Microsoft Corporation
#
# Updated on: 10/27/2015
#

@{

# Script module or binary module file associated with this manifest
ModuleToProcess = 'Microsoft.AzureStack.Commands.dll'

# Version number of this module.
ModuleVersion = '0.9.1'

# ID used to uniquely identify this module
GUID = '0e691e0a-ce16-40f2-af84-86fb0d82fb29'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = 'Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Microsoft Azure Stack Administration Module'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '3.0'

# Name of the Windows PowerShell host required by this module
PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
PowerShellHostVersion = ''

# Minimum version of the .NET Framework required by this module
DotNetFrameworkVersion = '4.5'

# Minimum version of the common language runtime (CLR) required by this module
CLRVersion = '4.0'

# Processor architecture (None, X86, Amd64, IA64) required by this module
ProcessorArchitecture = ''

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

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @('AzureStackAdmin.format.ps1xml')

# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = @()

# Functions to export from this module
FunctionsToExport = '*'

# Cmdlets to export from this module
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module
AliasesToExport = '*'

# List of all modules packaged with this module
ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in ModuleToProcess
PrivateData = ''
}

39 changes: 39 additions & 0 deletions src/ResourceManager/AzureStackAdmin/AzureStackAdmin.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManager.Common", "..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj", "{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Profile", "..\Profile\Commands.Profile\Commands.Profile.csproj", "{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common", "..\..\Common\Commands.Common\Commands.Common.csproj", "{5EE72C53-1720-4309-B54B-5FB79703195F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.AzureStackAdmin", "Commands.AzureStackAdmin\Commands.AzureStackAdmin.csproj", "{0B02390C-8AA9-4D99-8AA8-2A9D2D39682F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Release|Any CPU.Build.0 = Release|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
{5EE72C53-1720-4309-B54B-5FB79703195F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EE72C53-1720-4309-B54B-5FB79703195F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EE72C53-1720-4309-B54B-5FB79703195F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EE72C53-1720-4309-B54B-5FB79703195F}.Release|Any CPU.Build.0 = Release|Any CPU
{0B02390C-8AA9-4D99-8AA8-2A9D2D39682F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B02390C-8AA9-4D99-8AA8-2A9D2D39682F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B02390C-8AA9-4D99-8AA8-2A9D2D39682F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B02390C-8AA9-4D99-8AA8-2A9D2D39682F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.AzureStack.Commands
{
using System;
using System.Management.Automation;
using System.Net;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.Azure.Commands.ResourceManager.Common;
using Microsoft.Azure.Common.Authentication;
using Microsoft.Azure.Common.Authentication.Models;
using Microsoft.Azure;
using Microsoft.AzureStack.Management;

/// <summary>
/// Base Admin API cmdlet class
/// </summary>
public abstract class AdminApiCmdlet : AzureRMCmdlet
{
/// <summary>
/// The default API version.
/// </summary>
private const string DefaultApiVersion = "1.0";

/// <summary>
/// Gets or sets the admin base URI
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
[ValidateNotNull]
[ValidateAbsoluteUri]
public Uri AdminUri { get; set; }

/// <summary>
/// Gets or sets the authentication token
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
[ValidateNotNull]
public string Token { get; set; }

/// <summary>
/// Gets or sets the API version.
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true)]
[ValidateNotNull]
public string ApiVersion { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to disable certificate validation.
/// </summary>
[Parameter]
public SwitchParameter DisableCertificateValidation { get; set; }

/// <summary>
/// Gets the current default context. overriding it here since DefaultContext could be null for Windows Auth/ADFS environments
/// </summary>
protected override AzureContext DefaultContext
{
get
{
if (DefaultProfile == null)
{
return null;
}

return DefaultProfile.Context;
}
}

/// <summary>
/// Execute this cmdlet.
/// </summary>
/// <remarks>
/// Descendant classes must override this methods instead of Cmdlet.ProcessRecord, so
/// we can have a unique place where log all errors.
/// </remarks>
protected override void ProcessRecord()
{
var originalValidateCallback = ServicePointManager.ServerCertificateValidationCallback;
object result;

this.ValidateParameters();

try
{
// Note: (bryanr) Adding the tracing interceptor requires using a message pump and action queue. See relevant thread in PowerShell Discussions.
////CloudContext.Configuration.Tracing.AddTracingInterceptor(this);

// TODO (bryanr) - Evaluate if this should be removed entirely
if (this.DisableCertificateValidation)
{
this.WriteWarning(Resources.WarningDisableCertificateValidation);
ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true;
}

// Initialize parameters bound from the pipeline
this.ApiVersion = this.ApiVersion ?? DefaultApiVersion;

// Execute the API call(s) for the current cmdlet
result = this.ExecuteCore();
}
finally
{
if (this.DisableCertificateValidation)
{
ServicePointManager.ServerCertificateValidationCallback = originalValidateCallback;
}

////CloudContext.Configuration.Tracing.RemoveTracingInterceptor(this);
}

// Write the object to the pipeline only after the certificate validation callback has been restored.
// This will prevent other cmdlets in the pipeline from inheriting this security vulnerability.
if (result != null)
{
this.WriteObject(result, enumerateCollection: true);
}
}

private void ValidateParameters()
{
// if Token is empty, make sure that we have a valid azure profile
if (string.IsNullOrEmpty(this.Token))
{
if (this.DefaultContext == null)
{
throw new ApplicationException(Resources.InvalidProfile);
}
}
else
{
// if token is specified, AdminUri is required as well
if (this.AdminUri == null)
{
throw new ApplicationException(Resources.TokenAndAdminUriRequired);
}
}
}

/// <summary>
/// Executes the API call(s) against Azure Resource Management API(s).
/// </summary>
protected abstract object ExecuteCore();

/// <summary>
/// Gets the Azure Stack management client.
/// </summary>
/// <param name="subscriptionId">The subscription identifier.</param>
protected AzureStackClient GetAzureStackClient(string subscriptionId = null)
{
if (string.IsNullOrEmpty(this.Token))
{
return GetAzureStackClientThruAzureSession();
}

if (string.IsNullOrEmpty(subscriptionId))
{
return new AzureStackClient(
baseUri: this.AdminUri,
credentials: new TokenCloudCredentials(token: this.Token),
apiVersion: this.ApiVersion);
}
else
{
return new AzureStackClient(
baseUri: this.AdminUri,
credentials: new TokenCloudCredentials(subscriptionId: subscriptionId, token: this.Token),
apiVersion: this.ApiVersion);
}
}

/// <summary>
/// Gets the Azures Stack management client.
/// </summary>
/// <param name="subscriptionId">The subscription identifier.</param>
protected AzureStackClient GetAzureStackClient(Guid subscriptionId)
{
return this.GetAzureStackClient(subscriptionId.ToString());
}

private AzureStackClient GetAzureStackClientThruAzureSession()
{
var armUri = this.DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager);
var credentials = AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(this.DefaultContext);

return AzureSession.ClientFactory.CreateCustomClient<AzureStackClient>(armUri, credentials, this.ApiVersion);
}
}
}
Loading