зеркало из
1
0
Форкнуть 0

Moved all Stack modules into StackAdmin folder.

This commit is contained in:
MiYanni 2018-08-17 14:18:13 -07:00
Родитель 25a99ee441
Коммит 04cc3acf4d
1700 изменённых файлов: 3307085 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,239 @@
#
# Module manifest for module 'PSGet_AzureRM.Compute'
#
# Generated by: Microsoft Corporation
#
# Generated on: 7/6/2017
#
@{
# Script module or binary module file associated with this manifest.
# RootModule = ''
# Version number of this module.
ModuleVersion = '1.2.3.4'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = '0a83c907-1ffb-4d87-a492-c65ac7d7ed37'
# 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 PowerShell - Compute service cmdlets for Azure Resource Manager. Manages virtual machines, hosted services, and related resources in Azure Resource Manager'
# 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 Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
DotNetFrameworkVersion = '4.5.2'
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
CLRVersion = '4.0'
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '4.1.1'; })
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = '.\Microsoft.Azure.Commands.Compute.Types.ps1xml'
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = '.\Microsoft.Azure.Commands.Compute.format.ps1xml',
'.\Microsoft.Azure.Commands.Compute.format.generated.ps1xml',
'.\Generated\Microsoft.Azure.Commands.Compute.Automation.format.generated.ps1xml'
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('.\Microsoft.Azure.Commands.Compute.dll')
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = 'Remove-AzureRmAvailabilitySet', 'Get-AzureRmAvailabilitySet',
'New-AzureRmAvailabilitySet', 'Update-AzureRmAvailabilitySet',
'Get-AzureRmVMExtensionImageType', 'Get-AzureRmVMExtensionImage',
'Get-AzureRmVMADDomainExtension', 'Set-AzureRmVMADDomainExtension',
'Get-AzureRmVMAEMExtension', 'Remove-AzureRmVMAEMExtension',
'Set-AzureRmVMAEMExtension', 'Test-AzureRmVMAEMExtension',
'Set-AzureRmVMBginfoExtension',
'Get-AzureRmVMCustomScriptExtension',
'Remove-AzureRmVMCustomScriptExtension',
'Set-AzureRmVMCustomScriptExtension',
'Get-AzureRmVMDiagnosticsExtension',
'Remove-AzureRmVMDiagnosticsExtension',
'Remove-AzureRmVmssDiagnosticsExtension',
'Set-AzureRmVMDiagnosticsExtension', 'Set-AzureRmVMExtension',
'Remove-AzureRmVMExtension', 'Get-AzureRmVMExtension',
'Get-AzureRmVMSqlServerExtension',
'New-AzureRmVMSqlServerAutoBackupConfig',
'New-AzureRmVMSqlServerAutoPatchingConfig',
'New-AzureRmVMSqlServerKeyVaultCredentialConfig',
'Remove-AzureRmVMSqlServerExtension',
'Set-AzureRmVMSqlServerExtension', 'Get-AzureRmVMImage',
'Get-AzureRmVMAccessExtension', 'Remove-AzureRmVMAccessExtension',
'Set-AzureRmVMAccessExtension', 'Get-AzureRmVMImageSku',
'Get-AzureRmVMImagePublisher', 'Get-AzureRmVMImageOffer',
'Get-AzureRmRemoteDesktopFile', 'Get-AzureRmVMUsage',
'Get-AzureRmVMSize', 'Save-AzureRmVMImage', 'Set-AzureRmVM',
'Add-AzureRmVMAdditionalUnattendContent',
'Add-AzureRmVMSshPublicKey', 'Add-AzureRmVMSecret',
'Remove-AzureRmVMSecret', 'Remove-AzureRmVMNetworkInterface',
'Remove-AzureRmVMDataDisk', 'Set-AzureRmVMBootDiagnostics',
'Set-AzureRmVMDataDisk', 'Set-AzureRmVMPlan',
'Set-AzureRmVMSourceImage', 'Set-AzureRmVMOSDisk',
'Get-AzureRmVMBootDiagnosticsData', 'Get-AzureRmVM',
'Update-AzureRmVM', 'Restart-AzureRmVM', 'New-AzureRmVM',
'Start-AzureRmVM', 'Stop-AzureRmVM', 'Remove-AzureRmVM',
'New-AzureRmVMConfig', 'Set-AzureRmVMOperatingSystem',
'Add-AzureRmVMDataDisk', 'Add-AzureRmVMNetworkInterface',
'Add-AzureRmVhd', 'Save-AzureRmVhd',
'Add-AzureRmContainerServiceAgentPoolProfile',
'New-AzureRmContainerServiceConfig',
'Remove-AzureRmContainerServiceAgentPoolProfile',
'New-AzureRmContainerService', 'Update-AzureRmContainerService',
'Remove-AzureRmContainerService', 'Get-AzureRmContainerService',
'Get-AzureRmVmssVM', 'Set-AzureRmVmssVM',
'Add-AzureRmVmssAdditionalUnattendContent',
'Add-AzureRmVmssExtension', 'Add-AzureRmVmssDataDisk',
'Add-AzureRmVmssNetworkInterfaceConfiguration',
'Add-AzureRmVmssSecret', 'Add-AzureRmVmssSshPublicKey',
'Add-AzureRmVmssWinRMListener', 'New-AzureRmVmssConfig',
'New-AzureRmVmssIpConfig', 'New-AzureRmVmssVaultCertificateConfig',
'Remove-AzureRmVmssExtension', 'Remove-AzureRmVmssDataDisk',
'Remove-AzureRmVmssNetworkInterfaceConfiguration',
'Set-AzureRmVmssOsProfile', 'Set-AzureRmVmssStorageProfile',
'New-AzureRmVmss', 'Update-AzureRmVmss', 'Stop-AzureRmVmss',
'Remove-AzureRmVmss', 'Get-AzureRmVmss', 'Get-AzureRmVmssSku',
'Set-AzureRmVmss', 'Restart-AzureRmVmss', 'Start-AzureRmVmss',
'Update-AzureRmVmssInstance', 'Get-AzureRmVMDscExtensionStatus',
'Publish-AzureRmVMDscConfiguration', 'Remove-AzureRmVMDscExtension',
'Set-AzureRmVMDscExtension', 'Get-AzureRmVMDscExtension',
'Add-AzureRmVmssDiagnosticsExtension', 'Get-AzureRmVMChefExtension',
'Remove-AzureRmVMChefExtension', 'Set-AzureRmVMChefExtension',
'Remove-AzureRmVMBackup', 'Disable-AzureRmVMDiskEncryption',
'Get-AzureRmVMDiskEncryptionStatus',
'Remove-AzureRmVMDiskEncryptionExtension',
'Set-AzureRmVMDiskEncryptionExtension',
'Set-AzureRmVMBackupExtension', 'New-AzureRmDisk',
'Update-AzureRmDisk', 'Get-AzureRmDisk', 'Remove-AzureRmDisk',
'Grant-AzureRmDiskAccess', 'Revoke-AzureRmDiskAccess',
'New-AzureRmDiskConfig', 'Set-AzureRmDiskDiskEncryptionKey',
'Set-AzureRmDiskImageReference', 'Set-AzureRmDiskKeyEncryptionKey',
'New-AzureRmDiskUpdateConfig',
'Set-AzureRmDiskUpdateDiskEncryptionKey',
'Set-AzureRmDiskUpdateImageReference',
'Set-AzureRmDiskUpdateKeyEncryptionKey', 'New-AzureRmSnapshot',
'Update-AzureRmSnapshot', 'Get-AzureRmSnapshot',
'Remove-AzureRmSnapshot', 'Grant-AzureRmSnapshotAccess',
'Revoke-AzureRmSnapshotAccess', 'New-AzureRmSnapshotConfig',
'Set-AzureRmSnapshotDiskEncryptionKey',
'Set-AzureRmSnapshotImageReference',
'Set-AzureRmSnapshotKeyEncryptionKey',
'New-AzureRmSnapshotUpdateConfig',
'Set-AzureRmSnapshotUpdateDiskEncryptionKey',
'Set-AzureRmSnapshotUpdateImageReference',
'Set-AzureRmSnapshotUpdateKeyEncryptionKey', 'New-AzureRmImage',
'Update-AzureRmImage', 'Get-AzureRmImage', 'Remove-AzureRmImage',
'New-AzureRmImageConfig', 'Set-AzureRmImageOsDisk',
'Add-AzureRmImageDataDisk', 'Remove-AzureRmImageDataDisk',
'ConvertTo-AzureRmVMManagedDisk', 'Set-AzureRmVmssBootDiagnostic',
'Get-AzureRmComputeResourceSku'
# Variables to export from this module
# VariablesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# 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 RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Azure','ResourceManager','ARM','Compute','IAAS','VM','VirtualMachine'
# A URL to the license for this module.
LicenseUri = 'https://aka.ms/azps-license'
# A URL to the main website for this project.
ProjectUri = 'https://github.com/Azure/azure-powershell'
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
ReleaseNotes = '* Storage account type support for Image disk:
- ''StorageAccountType'' parameter is added to Set-AzureRmImageOsDisk and Add-AzureRmImageDataDisk
* PrivateIP and PublicIP feature in Vmss Ip Configuration:
- ''PrivateIPAddressVersion'', ''PublicIPAddressConfigurationName'', ''PublicIPAddressConfigurationIdleTimeoutInMinutes'', ''DnsSetting'' names are added to New-AzureRmVmssIpConfig
- ''PrivateIPAddressVersion'' parameter for specifying IPv4 or IPv6 is added to New-AzureRmVmssIpConfig
* Performance Maintenance feature:
- ''PerformMaintenance'' switch parameter is added to Restart-AzureRmVM.
- Get-AzureRmVM -Status shows the information of performance maintenance of the given VM
* Virtual Machine Identity feature:
- ''IdentityType'' parameter is added to New-AzureRmVMConfig and UpdateAzureRmVM
- Get-AzureRmVM shows the information of the identity of the given VM
* Vmss Identity feature:
- ''IdentityType'' parameter is added to to New-AzureRmVmssConfig
- Get-AzureRmVmss shows the information of the identity of the given Vmss
* Vmss Boot Diagnostics feature:
- New cmdlet for setting boot diagnostics of Vmss object: Set-AzureRmVmssBootDiagnostics
- ''BootDiagnostic'' parameter is added to New-AzureRmVmssConfig
* Vmss LicenseType feature:
- ''LicenseType'' parameter is added to New-AzureRmVmssConfig
* RecoveryPolicyMode support:
- ''RecoveryPolicyMode'' paramter is added to New-AzureRmVmssConfig
* Compute Resource Sku feature:
- New cmdlet ''Get-AzureRmComputeResourceSku'' list all compute resource skus
'
# External dependent modules of this module
# ExternalModuleDependencies = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

Просмотреть файл

@ -0,0 +1,446 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('..\..\..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{37C44181-3F1B-4ABD-8089-26DFAB4B6BA8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Azure.Commands.Compute.Test</RootNamespace>
<AssemblyName>Microsoft.Azure.Commands.Compute.Test</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>5620997e</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>true</DelaySign>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;SIGN</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<Reference Include="Hyak.Common">
<HintPath>..\..\..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common.NetFramework">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Gallery">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Graph.RBAC">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.Azure.Graph.RBAC.3.4.0-preview\lib\net452\Microsoft.Azure.Graph.RBAC.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Authorization">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.9.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.Framework">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.6179.26854-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.7-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.12\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.13\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework">
<HintPath>..\..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.5.0-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\xunit.extensibility.core.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Common\ComputeTestController.cs" />
<Compile Include="ScenarioTests\AddVhdTests.cs" />
<Compile Include="ScenarioTests\ComputeCloudExceptionTests.cs" />
<Compile Include="ScenarioTests\DiagnosticsExtensionTests.cs" />
<Compile Include="ScenarioTests\DscExtensionTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineBootDiagnosticsTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineScaleSetTests.cs" />
<Compile Include="ScenarioTests\VMDynamicTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineProfileTests.cs" />
<Compile Include="ScenarioTests\AvailabilitySetTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineExtensionTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineNetworkInterfaceTests.cs" />
<Compile Include="ScenarioTests\UtilityFunctionTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineTests.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Common\Commands.Common.Authentication.Abstractions\Commands.Common.Authentication.Abstractions.csproj">
<Project>{70527617-7598-4aef-b5bd-db9186b8184b}</Project>
<Name>Commands.Common.Authentication.Abstractions</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj">
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
<Name>Commands.ResourceManager.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Common\Commands.ScenarioTests.ResourceManager.Common\Commands.ScenarioTests.ResourceManager.Common.csproj">
<Project>{3436a126-edc9-4060-8952-9a1be34cdd95}</Project>
<Name>Commands.ScenarioTests.ResourceManager.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Common\Commands.Common.Storage\Commands.Common.Storage.csproj">
<Project>{65c3a86a-716d-4e7d-ab67-1db00b3bf72d}</Project>
<Name>Commands.Common.Storage</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Network\Stack\Commands.Network\Commands.Network.csproj">
<Project>{98cfd96b-a6bc-4f15-ae2c-603fc2b58981}</Project>
<Name>Commands.Network</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Storage\Stack\Commands.Management.Storage\Commands.Management.Storage.csproj">
<Project>{a50ab133-5c04-4a17-9054-f8343683ec23}</Project>
<Name>Commands.Management.Storage</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.Compute\Commands.Compute.csproj">
<Project>{52643bd5-6378-49bd-9f6e-dac9dd8a867b}</Project>
<Name>Commands.Compute</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\Common\Commands.ScenarioTests.ResourceManager.Common\Assert.ps1">
<Link>ScenarioTests\Assert.ps1</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\..\Common\Commands.ScenarioTests.ResourceManager.Common\AzureRM.Storage.ps1">
<Link>ScenarioTests\AzureRM.Storage.ps1</Link>
</None>
<None Include="..\..\..\Resources\Commands.Resources.Test\ScenarioTests\Common.ps1">
<Link>ScenarioTests\Common.ps1</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="ConfigFiles\DiagnosticsExtensionConfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="ScenarioTests\AddVhdTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ComputeCloudExceptionTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DscExtensionTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DummyConfig.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\Generated\VirtualMachineDynamicTest1.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\Generated\VirtualMachineDynamicTest2.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\Generated\VirtualMachineDynamicTest3.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\VirtualMachineBootDiagnosticsTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DiagnosticsExtensionTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\VirtualMachineScaleSetTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\VMDynamicTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
<None Include="ScenarioTests\VirtualMachineProfileTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\AvailabilitySetTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ComputeTestCommon.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\VirtualMachineExtensionTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\VirtualMachineNetworkInterfaceTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\VirtualMachineTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AddVhdTests\TestAddVhd.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AvailabilitySetTests\TestAvailabilitySet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.ComputeCloudExceptionTests\RunComputeCloudExceptionTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests\TestDiagnosticsExtensionBasic.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests\TestDiagnosticsExtensionCantListSepcifyStorageAccountKey.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests\TestDiagnosticsExtensionSepcifyStorageAccountName.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests\TestDiagnosticsExtensionSupportJsonConfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DscExtensionTests\TestGetAzureRmVMDscExtension.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineBootDiagnosticsTests\TestLinuxVirtualMachineBootDiagnostics.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineBootDiagnosticsTests\TestVirtualMachineBootDiagnostics.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineBootDiagnosticsTests\TestVirtualMachineBootDiagnosticsPremium.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineBootDiagnosticsTests\TestVirtualMachineBootDiagnosticsSet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineAccessExtension.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineBginfoExtension.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineCustomScriptExtension.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineCustomScriptExtensionFileUri.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineCustomScriptExtensionSecureExecution.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineExtension.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineExtensionUsingHashTable.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineExtensionWithSwitch.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineNetworkInterfaceTests\TestAddNetworkInterface.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineNetworkInterfaceTests\TestSingleNetworkInterfaceDnsSettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineNetworkInterfaceTests\TestVirtualMachineMultipleNetworkInterface.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineNetworkInterfaceTests\TestVirtualMachineSingleNetworkInterface.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineProfileTests\TestVirtualMachineProfileWithoutAUC.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests\TestVirtualMachineScaleSet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests\TestVirtualMachineScaleSetReimageUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestGetVMSizeFromAllLocations.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestLinuxVirtualMachine.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachine.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineProfileTests\TestVirtualMachineProfile.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineDataDisk.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineDataDiskNegative.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineImageList.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineList.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineCapture.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineListWithPaging.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachinePiping.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachinePIRv2.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachinePlan.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachinePlan2.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineRedeploy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineSizeAndUsage.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineTags.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineWithBYOL.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineWithDifferentStorageResource.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineWithEmptyAuc.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineWithVMAgentAutoUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVMImageCmdletOutputFormat.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VMDynamicTests\RunVMDynamicTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\azuredeploy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="ConfigFiles\DiagnosticsExtensionConfig.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,278 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Gallery;
using Microsoft.Azure.Graph.RBAC;
using Microsoft.Azure.Management.Authorization;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Subscriptions;
using Microsoft.Azure.Test;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public sealed class ComputeTestController : RMTestBase
{
bool testViaCsm = true; // Currently set to true, we will get this from Environment varialbe.
private CSMTestEnvironmentFactory csmTestFactory;
private EnvironmentSetupHelper helper;
private const string TenantIdKey = "TenantId";
private const string DomainKey = "Domain";
public GraphRbacManagementClient GraphClient { get; private set; }
public ResourceManagementClient ResourceManagementClient { get; private set; }
public SubscriptionClient SubscriptionClient { get; private set; }
public GalleryClient GalleryClient { get; private set; }
//public EventsClient EventsClient { get; private set; }
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
public StorageManagementClient StorageClient { get; private set; }
public NetworkManagementClient NetworkManagementClient { get; private set; }
public ComputeManagementClient ComputeManagementClient { get; private set; }
public string UserDomain { get; private set; }
public static ComputeTestController NewInstance
{
get
{
return new ComputeTestController();
}
}
public ComputeTestController()
{
helper = new EnvironmentSetupHelper();
}
public void RunPsTest(ServiceManagemenet.Common.Models.XunitTracingInterceptor logger, params string[] scripts)
{
var callingClassType = TestUtilities.GetCallingClass(2);
var mockName = TestUtilities.GetCurrentMethodName(2);
helper.TracingInterceptor = logger;
RunPsTestWorkflow(
() => scripts,
// no custom initializer
null,
// no custom cleanup
null,
callingClassType,
mockName);
}
public void RunPsTest(params string[] scripts)
{
var callingClassType = TestUtilities.GetCallingClass(2);
var mockName = TestUtilities.GetCurrentMethodName(2);
RunPsTestWorkflow(
() => scripts,
// no custom initializer
null,
// no custom cleanup
null,
callingClassType,
mockName);
}
public void RunPsTestWorkflow(
Func<string[]> scriptBuilder,
Action<CSMTestEnvironmentFactory> initialize,
Action cleanup,
string callingClassType,
string mockName)
{
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("Microsoft.Resources", null);
d.Add("Microsoft.Features", null);
d.Add("Microsoft.Authorization", null);
d.Add("Microsoft.Compute", null);
var providersToIgnore = new Dictionary<string, string>();
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
using (RestTestFramework.MockContext context = RestTestFramework.MockContext.Start(callingClassType, mockName))
{
this.csmTestFactory = new CSMTestEnvironmentFactory();
if (initialize != null)
{
initialize(this.csmTestFactory);
}
SetupManagementClients(context);
helper.SetupEnvironment(AzureModule.AzureResourceManager);
var callingClassName = callingClassType
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
.Last();
helper.SetupModules(AzureModule.AzureResourceManager,
"ScenarioTests\\Common.ps1",
"ScenarioTests\\ComputeTestCommon.ps1",
"ScenarioTests\\" + callingClassName + ".ps1",
helper.RMProfileModule,
helper.RMResourceModule,
#if !NETSTANDARD
helper.RMStorageDataPlaneModule,
#endif
helper.RMStorageModule,
helper.GetRMModulePath("AzureRM.Compute.psd1"),
helper.GetRMModulePath("AzureRM.Network.psd1"),
"AzureRM.Storage.ps1",
"AzureRM.Resources.ps1");
try
{
if (scriptBuilder != null)
{
var psScripts = scriptBuilder();
if (psScripts != null)
{
helper.RunPowerShellTest(psScripts);
}
}
}
finally
{
if (cleanup != null)
{
cleanup();
}
}
}
}
private void SetupManagementClients(RestTestFramework.MockContext context)
{
ResourceManagementClient = GetResourceManagementClient();
SubscriptionClient = GetSubscriptionClient();
StorageClient = GetStorageManagementClient(context);
GalleryClient = GetGalleryClient();
//var eventsClient = GetEventsClient();
NetworkManagementClient = this.GetNetworkManagementClientClient(context);
ComputeManagementClient = GetComputeManagementClient(context);
AuthorizationManagementClient = GetAuthorizationManagementClient();
// GraphClient = GetGraphClient();
helper.SetupManagementClients(
ResourceManagementClient,
SubscriptionClient,
StorageClient,
GalleryClient,
//eventsClient,
NetworkManagementClient,
ComputeManagementClient,
AuthorizationManagementClient);
// GraphClient);
}
private GraphRbacManagementClient GetGraphClient()
{
var environment = this.csmTestFactory.GetTestEnvironment();
string tenantId = null;
if (HttpMockServer.Mode == HttpRecorderMode.Record)
{
tenantId = environment.AuthorizationContext.TenantId;
UserDomain = environment.AuthorizationContext.UserDomain;
HttpMockServer.Variables[TenantIdKey] = tenantId;
HttpMockServer.Variables[DomainKey] = UserDomain;
}
else if (HttpMockServer.Mode == HttpRecorderMode.Playback)
{
if (HttpMockServer.Variables.ContainsKey(TenantIdKey))
{
tenantId = HttpMockServer.Variables[TenantIdKey];
}
if (HttpMockServer.Variables.ContainsKey(DomainKey))
{
UserDomain = HttpMockServer.Variables[DomainKey];
}
}
return TestBase.GetGraphServiceClient<GraphRbacManagementClient>(this.csmTestFactory, tenantId);
}
private AuthorizationManagementClient GetAuthorizationManagementClient()
{
return TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);
}
private ResourceManagementClient GetResourceManagementClient()
{
return TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
}
private SubscriptionClient GetSubscriptionClient()
{
return TestBase.GetServiceClient<SubscriptionClient>(this.csmTestFactory);
}
private StorageManagementClient GetStorageManagementClient(RestTestFramework.MockContext context)
{
return testViaCsm
? context.GetServiceClient<StorageManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment())
: TestBase.GetServiceClient<StorageManagementClient>(new RDFETestEnvironmentFactory());
}
private GalleryClient GetGalleryClient()
{
return TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);
}
//private EventsClient GetEventsClient()
//{
// return TestBase.GetServiceClient<EventsClient>(this.csmTestFactory);
//}
private NetworkManagementClient GetNetworkManagementClientClient(RestTestFramework.MockContext context)
{
return testViaCsm
? context.GetServiceClient<NetworkManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment())
: TestBase.GetServiceClient<NetworkManagementClient>(new RDFETestEnvironmentFactory());
}
private ComputeManagementClient GetComputeManagementClient(RestTestFramework.MockContext context)
{
return testViaCsm
? context.GetServiceClient<ComputeManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment())
: TestBase.GetServiceClient<ComputeManagementClient>(new RDFETestEnvironmentFactory());
}
}
}

Просмотреть файл

@ -0,0 +1,19 @@
@echo off
set "ROOTDIR=..\..\..\..\"
set "VSTOOLSDIR=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\"
set "VSINSTR="%VSTOOLSDIR%vsinstr.exe""
set "VSPERFCMD="%VSTOOLSDIR%VSPerfCmd.exe""
set "RESULT="%ROOTDIR%Project.coverage""
set "DLL="%ROOTDIR%src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.dll""
set "TEST="%ROOTDIR%src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.Test.dll""
set "XUNIT="%ROOTDIR%packages\xunit.runner.console.2.0.0\tools\xunit.console.x86.exe""
%VSINSTR% /COVERAGE %DLL%
%VSPERFCMD% /start:COVERAGE /OUTPUT:%RESULT%
%XUNIT% %TEST%
%VSPERFCMD% /SHUTDOWN

Просмотреть файл

@ -0,0 +1,100 @@
{
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"Directories": {
"IISLogs": {
"containerName": "wad-iis-logfiles"
},
"FailedRequestLogs": {
"containerName": "wad-failedrequestlogs"
},
"scheduledTransferPeriod": "PT1M"
},
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"annotation": [],
"counterSpecifier": "\\Memory\\Available MBytes",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Queued",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT3M"
}
],
"scheduledTransferPeriod": "PT1M"
},
"WindowsEventLog": {
"DataSource": [
{
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
},
{
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
}
],
"scheduledTransferPeriod": "PT1M"
},
"CrashDumps": {
"CrashDumpConfiguration": [
{
"processName": "WaIISHost.exe"
},
{
"processName": "WaWorkerHost.exe"
},
{
"processName": "w3wp.exe"
}
]
},
"Logs": {
"scheduledTransferLogLevelFilter": "Error",
"scheduledTransferPeriod": "PT1M"
},
"Metrics": {
"resourceId": "dummy",
"MetricAggregation": [
{
"scheduledTransferPeriod": "PT1M"
}
]
},
"overallQuotaInMB": 4096
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
<PublicConfig>
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="2048" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error" />
<Directories scheduledTransferPeriod="PT1M">
<IISLogs containerName="wad-iis-logfiles" />
<FailedRequestLogs containerName="wad-failedrequestlogs" />
</Directories>
<PerformanceCounters scheduledTransferPeriod="PT2M">
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
</PerformanceCounters>
<WindowsEventLog scheduledTransferPeriod="PT1M">
<DataSource name="Application!*[System[(Level=1 or Level=2)]]" />
<DataSource name="Windows Azure!*[System[(Level=1 or Level=2)]]" />
</WindowsEventLog>
<CrashDumps>
<CrashDumpConfiguration processName="WaIISHost.exe" />
<CrashDumpConfiguration processName="WaWorkerHost.exe" />
<CrashDumpConfiguration processName="w3wp.exe" />
</CrashDumps>
<Logs scheduledTransferPeriod="PT3M" />
<Metrics resourceId="dummy">
<MetricAggregation scheduledTransferPeriod="PT1M"/>
</Metrics>
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>[StorageAccountName]</StorageAccount>
</PublicConfig>

Просмотреть файл

@ -0,0 +1,107 @@
{
"PublicConfig": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"Directories": {
"IISLogs": {
"containerName": "wad-iis-logfiles"
},
"FailedRequestLogs": {
"containerName": "wad-failedrequestlogs"
},
"scheduledTransferPeriod": "PT1M"
},
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"annotation": [],
"counterSpecifier": "\\Memory\\Available MBytes",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Queued",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT3M"
}
],
"scheduledTransferPeriod": "PT1M"
},
"WindowsEventLog": {
"DataSource": [
{
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
},
{
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
}
],
"scheduledTransferPeriod": "PT1M"
},
"CrashDumps": {
"CrashDumpConfiguration": [
{
"processName": "WaIISHost.exe"
},
{
"processName": "WaWorkerHost.exe"
},
{
"processName": "w3wp.exe"
}
]
},
"Logs": {
"scheduledTransferLogLevelFilter": "Error",
"scheduledTransferPeriod": "PT1M"
},
"Metrics": {
"resourceId": "dummy",
"MetricAggregation": [
{
"scheduledTransferPeriod": "PT1M"
}
]
},
"overallQuotaInMB": 4096
}
}
},
"PrivateConfig": {
"storageAccountName": "[StorageAccountName]",
"storageAccountSasToken": "This-is-a-sas-token",
"storageAccountEndPoint": "This-is-an-endpoint"
}
}

Просмотреть файл

@ -0,0 +1,40 @@
<DiagnosticsConfiguration>
<PublicConfig>
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="2048" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error" />
<Directories scheduledTransferPeriod="PT1M">
<IISLogs containerName="wad-iis-logfiles" />
<FailedRequestLogs containerName="wad-failedrequestlogs" />
</Directories>
<PerformanceCounters scheduledTransferPeriod="PT2M">
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
</PerformanceCounters>
<WindowsEventLog scheduledTransferPeriod="PT1M">
<DataSource name="Application!*[System[(Level=1 or Level=2)]]" />
<DataSource name="Windows Azure!*[System[(Level=1 or Level=2)]]" />
</WindowsEventLog>
<CrashDumps>
<CrashDumpConfiguration processName="WaIISHost.exe" />
<CrashDumpConfiguration processName="WaWorkerHost.exe" />
<CrashDumpConfiguration processName="w3wp.exe" />
</CrashDumps>
<Logs scheduledTransferPeriod="PT3M" />
<Metrics resourceId="dummy">
<MetricAggregation scheduledTransferPeriod="PT1M"/>
</Metrics>
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>[StorageAccountName]</StorageAccount>
</PublicConfig>
<PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<StorageAccount name="[StorageAccountName]" sasToken="This-is-a-sas-token" endpoint="This-is-an-endpoint" />
</PrivateConfig>
</DiagnosticsConfiguration>

Просмотреть файл

@ -0,0 +1,101 @@
{
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"Directories": {
"IISLogs": {
"containerName": "wad-iis-logfiles"
},
"FailedRequestLogs": {
"containerName": "wad-failedrequestlogs"
},
"scheduledTransferPeriod": "PT1M"
},
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"annotation": [],
"counterSpecifier": "\\Memory\\Available MBytes",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Queued",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT3M"
}
],
"scheduledTransferPeriod": "PT1M"
},
"WindowsEventLog": {
"DataSource": [
{
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
},
{
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
}
],
"scheduledTransferPeriod": "PT1M"
},
"CrashDumps": {
"CrashDumpConfiguration": [
{
"processName": "WaIISHost.exe"
},
{
"processName": "WaWorkerHost.exe"
},
{
"processName": "w3wp.exe"
}
]
},
"Logs": {
"scheduledTransferLogLevelFilter": "Error",
"scheduledTransferPeriod": "PT1M"
},
"Metrics": {
"resourceId": "dummy",
"MetricAggregation": [
{
"scheduledTransferPeriod": "PT1M"
}
]
},
"overallQuotaInMB": 4096
}
},
"StorageType": "TableAndBlob"
}

Просмотреть файл

@ -0,0 +1,36 @@
<PublicConfig>
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="2048" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error" />
<Directories scheduledTransferPeriod="PT1M">
<IISLogs containerName="wad-iis-logfiles" />
<FailedRequestLogs containerName="wad-failedrequestlogs" />
</Directories>
<PerformanceCounters scheduledTransferPeriod="PT2M">
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
</PerformanceCounters>
<WindowsEventLog scheduledTransferPeriod="PT1M">
<DataSource name="Application!*[System[(Level=1 or Level=2)]]" />
<DataSource name="Windows Azure!*[System[(Level=1 or Level=2)]]" />
</WindowsEventLog>
<CrashDumps>
<CrashDumpConfiguration processName="WaIISHost.exe" />
<CrashDumpConfiguration processName="WaWorkerHost.exe" />
<CrashDumpConfiguration processName="w3wp.exe" />
</CrashDumps>
<Logs scheduledTransferPeriod="PT3M" />
<Metrics resourceId="dummy">
<MetricAggregation scheduledTransferPeriod="PT1M"/>
</Metrics>
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>[StorageAccountName]</StorageAccount>
<StorageType>TableAndBlob</StorageType>
</PublicConfig>

Просмотреть файл

@ -0,0 +1,107 @@
{
"PublicConfig": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"Directories": {
"IISLogs": {
"containerName": "wad-iis-logfiles"
},
"FailedRequestLogs": {
"containerName": "wad-failedrequestlogs"
},
"scheduledTransferPeriod": "PT1M"
},
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"annotation": [],
"counterSpecifier": "\\Memory\\Available MBytes",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Queued",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
"sampleRate": "PT3M"
},
{
"annotation": [],
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT3M"
}
],
"scheduledTransferPeriod": "PT1M"
},
"WindowsEventLog": {
"DataSource": [
{
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
},
{
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
}
],
"scheduledTransferPeriod": "PT1M"
},
"CrashDumps": {
"CrashDumpConfiguration": [
{
"processName": "WaIISHost.exe"
},
{
"processName": "WaWorkerHost.exe"
},
{
"processName": "w3wp.exe"
}
]
},
"Logs": {
"scheduledTransferLogLevelFilter": "Error",
"scheduledTransferPeriod": "PT1M"
},
"Metrics": {
"resourceId": "dummy",
"MetricAggregation": [
{
"scheduledTransferPeriod": "PT1M"
}
]
},
"overallQuotaInMB": 4096
}
}
},
"PrivateConfig": {
"storageAccountName": "This-is-a-wrong-name",
"storageAccountKey": "This-is-a-storage-account-key",
"storageAccountEndPoint": "This-is-an-endpoint"
}
}

Просмотреть файл

@ -0,0 +1,40 @@
<DiagnosticsConfiguration>
<PublicConfig>
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="2048" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error" />
<Directories scheduledTransferPeriod="PT1M">
<IISLogs containerName="wad-iis-logfiles" />
<FailedRequestLogs containerName="wad-failedrequestlogs" />
</Directories>
<PerformanceCounters scheduledTransferPeriod="PT2M">
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT1M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
</PerformanceCounters>
<WindowsEventLog scheduledTransferPeriod="PT1M">
<DataSource name="Application!*[System[(Level=1 or Level=2)]]" />
<DataSource name="Windows Azure!*[System[(Level=1 or Level=2)]]" />
</WindowsEventLog>
<CrashDumps>
<CrashDumpConfiguration processName="WaIISHost.exe" />
<CrashDumpConfiguration processName="WaWorkerHost.exe" />
<CrashDumpConfiguration processName="w3wp.exe" />
</CrashDumps>
<Logs scheduledTransferPeriod="PT3M" />
<Metrics resourceId="dummy">
<MetricAggregation scheduledTransferPeriod="PT1M"/>
</Metrics>
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>[StorageAccountName]</StorageAccount>
</PublicConfig>
<PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<StorageAccount name="This-is-a-wrong-name" sasToken="This-is-a-sas-token" endpoint="This-is-an-endpoint" />
</PrivateConfig>
</DiagnosticsConfiguration>

Просмотреть файл

@ -0,0 +1,3 @@
{
"storageAccountName": "[StorageAccountName]"
}

Просмотреть файл

@ -0,0 +1,5 @@
{
"storageAccountName": "[StorageAccountName]",
"storageAccountSasToken": "This-is-a-sas-token",
"storageAccountEndPoint": "This-is-an-endpoint"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"storageAccountName": "This-is-a-wrong-name"
}

Просмотреть файл

@ -0,0 +1,101 @@
{
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"Directories": {
"IISLogs": {
"containerName": "wad-iis-logfiles"
},
"FailedRequestLogs": {
"containerName": "wad-failedrequestlogs"
},
"scheduledTransferPeriod": "PT1M"
},
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"annotation": [ ],
"counterSpecifier": "\\Memory\\Available MBytes",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET\\Requests Queued",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT3M"
}
],
"scheduledTransferPeriod": "PT1M"
},
"WindowsEventLog": {
"DataSource": [
{
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
},
{
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
}
],
"scheduledTransferPeriod": "PT1M"
},
"CrashDumps": {
"CrashDumpConfiguration": [
{
"processName": "WaIISHost.exe"
},
{
"processName": "WaWorkerHost.exe"
},
{
"processName": "w3wp.exe"
}
]
},
"Logs": {
"scheduledTransferLogLevelFilter": "Error",
"scheduledTransferPeriod": "PT1M"
},
"Metrics": {
"resourceId": "dummy",
"MetricAggregation": [
{
"scheduledTransferPeriod": "PT1M"
}
]
},
"overallQuotaInMB": 4096
}
},
"StorageAccount": "[StorageAccountName]"
}

Просмотреть файл

@ -0,0 +1,101 @@
{
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"Directories": {
"IISLogs": {
"containerName": "wad-iis-logfiles"
},
"FailedRequestLogs": {
"containerName": "wad-failedrequestlogs"
},
"scheduledTransferPeriod": "PT1M"
},
"PerformanceCounters": {
"PerformanceCounterConfiguration": [
{
"annotation": [ ],
"counterSpecifier": "\\Memory\\Available MBytes",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET\\Requests Queued",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
"sampleRate": "PT3M"
},
{
"annotation": [ ],
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
"sampleRate": "PT3M"
}
],
"scheduledTransferPeriod": "PT1M"
},
"WindowsEventLog": {
"DataSource": [
{
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
},
{
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
}
],
"scheduledTransferPeriod": "PT1M"
},
"CrashDumps": {
"CrashDumpConfiguration": [
{
"processName": "WaIISHost.exe"
},
{
"processName": "WaWorkerHost.exe"
},
{
"processName": "w3wp.exe"
}
]
},
"Logs": {
"scheduledTransferLogLevelFilter": "Error",
"scheduledTransferPeriod": "PT1M"
},
"Metrics": {
"MetricAggregation": [
{
"scheduledTransferPeriod": "PT1M"
}
]
},
"overallQuotaInMB": 4096
}
},
"StorageAccount": "[StorageAccountName]",
"StorageType": "TableAndBlob"
}

Двоичные данные
Compute/Commands.Compute.Test/MSSharedLibKey.snk Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,37 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using System.Reflection;
using System.Runtime.InteropServices;
using Xunit;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Commands.Compute.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Microsoft.Azure.Commands.Compute.Test")]
[assembly: AssemblyCopyright("Copyright © Microsoft")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("28fe3fc0-6fdf-4f01-8a82-d7b4a834ddd2")]
[assembly: AssemblyVersion("3.3.2")]
[assembly: AssemblyFileVersion("3.3.2")]
[assembly: CollectionBehavior(DisableTestParallelization = true)]

63
Compute/Commands.Compute.Test/Properties/Resources.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Microsoft.Azure.Commands.Compute.Test.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Azure.Commands.Compute.Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

Просмотреть файл

@ -0,0 +1,86 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class AEMExtensionTests
{
public AEMExtensionTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
public void TestAEMExtensionBasicWindowsWAD()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionBasicWindowsWAD");
}
[Fact]
public void TestAEMExtensionBasicWindows()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionBasicWindows");
}
[Fact]
public void TestAEMExtensionBasicLinuxWAD()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionBasicLinuxWAD");
}
[Fact]
public void TestAEMExtensionBasicLinux()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionBasicLinux");
}
[Fact]
public void TestAEMExtensionAdvancedWindowsWAD()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedWindowsWAD");
}
[Fact]
public void TestAEMExtensionAdvancedWindows()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedWindows");
}
[Fact]
public void TestAEMExtensionAdvancedLinuxWAD()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedLinuxWAD");
}
[Fact]
public void TestAEMExtensionAdvancedLinux()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedLinux");
}
[Fact]
public void TestAEMExtensionAdvancedWindowsMD()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedWindowsMD");
}
[Fact]
public void TestAEMExtensionAdvancedLinuxMD()
{
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedLinuxMD");
}
}
}

Просмотреть файл

@ -0,0 +1,761 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Test the basic usage of the Set/Get/Test/Remove virtual machine Azure Enhanced Monitoring extension command
#>
function Test-AEMExtensionBasicWindowsWAD
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc
$vmname = $vm.Name
# Get with not extension
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-False { $testResult.Result }
# Set and Get command.
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorage -EnableWAD
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.AzureCAT.AzureEnhancedMonitoring'
Assert-AreEqual $extension.ExtensionType 'AzureCATExtensionHandler'
Assert-AreEqual $extension.Name 'AzureCATExtensionHandler'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
# Test command.
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WaitTimeInMinutes 50 -SkipStorageCheck
Assert-True { $testResult.Result }
Assert-True { ($testResult.PartialResults.Count -gt 0) }
# Remove command.
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionBasicWindows
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc
$vmname = $vm.Name
# Get with not extension
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-False { $testResult.Result }
# Set and Get command.
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorage
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.AzureCAT.AzureEnhancedMonitoring'
Assert-AreEqual $extension.ExtensionType 'AzureCATExtensionHandler'
Assert-AreEqual $extension.Name 'AzureCATExtensionHandler'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
# Test command.
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WaitTimeInMinutes 50 -SkipStorageCheck
Assert-True { $testResult.Result }
Assert-True { ($testResult.PartialResults.Count -gt 0) }
# Remove command.
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionAdvancedWindowsWAD
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
Write-Verbose "Start the test Test-AEMExtensionAdvancedWindows"
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -vmsize 'Standard_DS2' -stotype 'Premium_LRS' -nicCount 2
$vmname = $vm.Name
Write-Verbose "Test-AEMExtensionAdvancedWindows: VM created"
# Get with not extension
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get with no extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test with no extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-False { $res.Result }
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test done"
$stoname = 'sto' + $rgname + "2";
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type 'Standard_LRS';
# Set and Get command.
Write-Verbose "Test-AEMExtensionAdvancedWindows: Set with no extension"
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WADStorageAccountName $stoname -SkipStorage -EnableWAD
Write-Verbose "Test-AEMExtensionAdvancedWindows: Set done"
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get with extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.AzureCAT.AzureEnhancedMonitoring'
Assert-AreEqual $extension.ExtensionType 'AzureCATExtensionHandler'
Assert-AreEqual $extension.Name 'AzureCATExtensionHandler'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get done"
# Test command.
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test with extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-True { $res.Result }
Assert-True { ($res.PartialResults.Count -gt 0) }
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test done"
# Remove command.
Write-Verbose "Test-AEMExtensionAdvancedWindows: Remove with extension"
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Write-Verbose "Test-AEMExtensionAdvancedWindows: Remove done"
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get after remove"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get after remove done"
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionAdvancedWindows
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
Write-Verbose "Start the test Test-AEMExtensionAdvancedWindows"
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -vmsize 'Standard_DS2' -stotype 'Premium_LRS' -nicCount 2
$vmname = $vm.Name
Write-Verbose "Test-AEMExtensionAdvancedWindows: VM created"
# Get with not extension
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get with no extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test with no extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-False { $res.Result }
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test done"
$stoname = 'sto' + $rgname + "2";
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type 'Standard_LRS';
# Set and Get command.
Write-Verbose "Test-AEMExtensionAdvancedWindows: Set with no extension"
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WADStorageAccountName $stoname -SkipStorage
Write-Verbose "Test-AEMExtensionAdvancedWindows: Set done"
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get with extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.AzureCAT.AzureEnhancedMonitoring'
Assert-AreEqual $extension.ExtensionType 'AzureCATExtensionHandler'
Assert-AreEqual $extension.Name 'AzureCATExtensionHandler'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get done"
# Test command.
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test with extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-True { $res.Result }
Assert-True { ($res.PartialResults.Count -gt 0) }
Write-Verbose "Test-AEMExtensionAdvancedWindows: Test done"
# Remove command.
Write-Verbose "Test-AEMExtensionAdvancedWindows: Remove with extension"
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Write-Verbose "Test-AEMExtensionAdvancedWindows: Remove done"
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get after remove"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
Write-Verbose "Test-AEMExtensionAdvancedWindows: Get after remove done"
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionAdvancedWindowsMD
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
Write-Verbose "Start the test Test-AEMExtensionAdvancedWindowsMD"
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -vmsize 'Standard_DS2' -stotype 'Premium_LRS' -nicCount 2 -useMD
$vmname = $vm.Name
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: VM created"
# Get with not extension
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Get with no extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Test with no extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-False { $res.Result }
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Test done"
$stoname = 'sto' + $rgname + "2";
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type 'Standard_LRS';
# Set and Get command.
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Set with no extension"
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WADStorageAccountName $stoname -SkipStorage
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Set done"
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Get with extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.AzureCAT.AzureEnhancedMonitoring'
Assert-AreEqual $extension.ExtensionType 'AzureCATExtensionHandler'
Assert-AreEqual $extension.Name 'AzureCATExtensionHandler'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
Assert-True { ($extension.PublicSettings.Contains("osdisk.caching")) }
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Get done"
# Test command.
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Test with extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-True { $res.Result }
Assert-True { ($res.PartialResults.Count -gt 0) }
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Test done"
# Remove command.
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Remove with extension"
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Remove done"
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Get after remove"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
Write-Verbose "Test-AEMExtensionAdvancedWindowsMD: Get after remove done"
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionAdvancedLinuxMD
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
Write-Host "Start the test Test-AEMExtensionAdvancedLinuxMD"
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -vmsize 'Standard_DS2' -stotype 'Premium_LRS' -nicCount 2 -useMD -linux
$vmname = $vm.Name
$vm = Get-AzureRmVM -ResourceGroupName $rgname -Name $vmname
Add-AzureRmVMDataDisk -VM $vm -StorageAccountType PremiumLRS -Lun (($vm.StorageProfile.DataDisks | select -ExpandProperty Lun | Measure-Object -Maximum).Maximum + 1) -CreateOption Empty -DiskSizeInGB 1023 | Update-AzureRmVM
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: VM created"
# Get with not extension
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Get with no extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension "Extension is not null"
# Test with not extension
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Test with no extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
$tmp = $res;$out = &{while ($true) { if ($tmp) { foreach ($tmpRes in $tmp) {($tmpRes.TestName + " " + $tmpRes.Result)};$tmp = @($tmp.PartialResults)} else {break}}};
Assert-False { $res.Result } "Test result is not false $out"
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Test done"
$stoname = 'sto' + $rgname + "2";
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type 'Standard_LRS';
# Set and Get command.
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Set with no extension"
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WADStorageAccountName $stoname -SkipStorage
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Set done"
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Get with extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.OSTCExtensions'
Assert-AreEqual $extension.ExtensionType 'AzureEnhancedMonitorForLinux'
Assert-AreEqual $extension.Name 'AzureEnhancedMonitorForLinux'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Get done"
# Test command.
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Test with extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
$tmp = $res;$out = &{while ($true) { if ($tmp) { foreach ($tmpRes in $tmp) {($tmpRes.TestName + " " + $tmpRes.Result)};$tmp = @($tmp.PartialResults)} else {break}}};
Assert-True { $res.Result } "Test result is not false $out"
Assert-True { ($res.PartialResults.Count -gt 0) }
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Test done"
# Remove command.
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Remove with extension"
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Remove done"
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Get after remove"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
Write-Verbose "Test-AEMExtensionAdvancedLinuxMD: Get after remove done"
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionBasicLinuxWAD
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -linux
$vmname = $vm.Name
# Get with not extension
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-False { $testResult.Result }
# Set and Get command.
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorage -EnableWAD
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.OSTCExtensions'
Assert-AreEqual $extension.ExtensionType 'AzureEnhancedMonitorForLinux'
Assert-AreEqual $extension.Name 'AzureEnhancedMonitorForLinux'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
# Test command.
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WaitTimeInMinutes 50 -SkipStorageCheck
Assert-True { $testResult.Result }
Assert-True { ($testResult.PartialResults.Count -gt 0) }
# Remove command.
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionBasicLinux
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -linux
$vmname = $vm.Name
# Get with not extension
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-False { $testResult.Result }
# Set and Get command.
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorage
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.OSTCExtensions'
Assert-AreEqual $extension.ExtensionType 'AzureEnhancedMonitorForLinux'
Assert-AreEqual $extension.Name 'AzureEnhancedMonitorForLinux'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
# Test command.
$testResult = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WaitTimeInMinutes 50 -SkipStorageCheck
Assert-True { $testResult.Result }
Assert-True { ($testResult.PartialResults.Count -gt 0) }
# Remove command.
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionAdvancedLinuxWAD
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
Write-Verbose "Start the test Test-AEMExtensionAdvancedLinux"
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -vmsize 'Standard_DS2' -stotype 'Premium_LRS' -nicCount 2 -linux
$vmname = $vm.Name
Write-Verbose "Test-AEMExtensionAdvancedLinux: VM created"
# Get with not extension
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get with no extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test with no extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Write-Verbose ("Test-AEMExtensionAdvancedLinux: Test result " + $res.Result)
Assert-False { $res.Result }
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test done"
$stoname = 'sto' + $rgname + "2";
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type 'Standard_LRS';
# Set and Get command.
Write-Verbose "Test-AEMExtensionAdvancedLinux: Set with no extension"
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WADStorageAccountName $stoname -SkipStorage -EnableWAD
Write-Verbose "Test-AEMExtensionAdvancedLinux: Set done"
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get with extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.OSTCExtensions'
Assert-AreEqual $extension.ExtensionType 'AzureEnhancedMonitorForLinux'
Assert-AreEqual $extension.Name 'AzureEnhancedMonitorForLinux'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get done"
# Test command.
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test with extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-True { $res.Result }
Assert-True { ($res.PartialResults.Count -gt 0) }
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test done"
# Remove command.
Write-Verbose "Test-AEMExtensionAdvancedLinux: Remove with extension"
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Write-Verbose "Test-AEMExtensionAdvancedLinux: Remove done"
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get after remove"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get after remove done"
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-AEMExtensionAdvancedLinux
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
Write-Verbose "Start the test Test-AEMExtensionAdvancedLinux"
# Setup
$vm = Create-AdvancedVM -rgname $rgname -loc $loc -vmsize 'Standard_DS2' -stotype 'Premium_LRS' -nicCount 2 -linux
$vmname = $vm.Name
Write-Verbose "Test-AEMExtensionAdvancedLinux: VM created"
# Get with not extension
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get with no extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
# Test with not extension
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test with no extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Write-Verbose ("Test-AEMExtensionAdvancedLinux: Test result " + $res.Result)
Assert-False { $res.Result }
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test done"
$stoname = 'sto' + $rgname + "2";
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type 'Standard_LRS';
# Set and Get command.
Write-Verbose "Test-AEMExtensionAdvancedLinux: Set with no extension"
Set-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -WADStorageAccountName $stoname -SkipStorage
Write-Verbose "Test-AEMExtensionAdvancedLinux: Set done"
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get with extension"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.OSTCExtensions'
Assert-AreEqual $extension.ExtensionType 'AzureEnhancedMonitorForLinux'
Assert-AreEqual $extension.Name 'AzureEnhancedMonitorForLinux'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-NotNull $settings.cfg
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get done"
# Test command.
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test with extension"
$res = Test-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname -SkipStorageCheck
Assert-True { $res.Result }
Assert-True { ($res.PartialResults.Count -gt 0) }
Write-Verbose "Test-AEMExtensionAdvancedLinux: Test done"
# Remove command.
Write-Verbose "Test-AEMExtensionAdvancedLinux: Remove with extension"
Remove-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Write-Verbose "Test-AEMExtensionAdvancedLinux: Remove done"
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get after remove"
$extension = Get-AzureRmVMAEMExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
Write-Verbose "Test-AEMExtensionAdvancedLinux: Get after remove done"
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Create-AdvancedVM($rgname, $vmname, $loc, $vmsize, $stotype, $nicCount, [Switch] $linux, [Switch] $useMD)
{
# Initialize parameters
$rgname = if ([string]::IsNullOrEmpty($rgname)) { Get-ComputeTestResourceName } else { $rgname }
$vmname = if ([string]::IsNullOrEmpty($vmname)) { 'vm' + $rgname } else { $vmname }
$loc = if ([string]::IsNullOrEmpty($loc)) { Get-ComputeVMLocation } else { $loc }
$vmsize = if ([string]::IsNullOrEmpty($vmsize)) { 'Standard_A2' } else { $vmsize }
$stotype = if ([string]::IsNullOrEmpty($stotype)) { 'Standard_LRS' } else { $stotype }
$nicCount = if ([string]::IsNullOrEmpty($nicCount)) { 1 } else { [int]$nicCount }
# Common
$g = New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# VM Profile & Hardware
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$pibparams = @{}
$pibparams.Add("PublicIpAddressId", $pubip.Id)
$nicPrimParams = @{}
$nicPrimParams.Add("Primary", $true)
for ($i = 0;$i -lt $nicCount;$i++)
{
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $i + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId @pibparams
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $i + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId @nicPrimParams;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[$i].Id $nicId;
$pibparams = @{}
$nicPrimParams = @{}
}
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count $nicCount;
# Storage Account (SA)
$stoname = 'sto' + $rgname;
$s = New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
$stokey = (Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname).Key1;
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";
$osURI = @{}
$disk1Uri = @{}
$disk2Uri = @{}
$disk3Uri = @{}
if (-not $useMD)
{
$osURI = @{"VhdUri"=$osDiskVhdUri}
$disk1Uri = @{"VhdUri"=$dataDiskVhdUri1}
$disk2Uri = @{"VhdUri"=$dataDiskVhdUri2}
$disk3Uri = @{"VhdUri"=$dataDiskVhdUri3}
}
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName @osURI -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 @disk1Uri -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 @disk2Uri -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 @disk3Uri -CreateOption Empty;
$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';
Assert-AreEqual $p.StorageProfile.OsDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OsDisk.Name $osDiskName;
if (-not $useMD)
{
Assert-AreEqual $p.StorageProfile.OsDisk.Vhd.Uri $osDiskVhdUri;
}
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
if (-not $useMD)
{
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
}
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
if (-not $useMD)
{
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;
}
# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
if ($linux)
{
$p = Set-AzureRmVMOperatingSystem -VM $p -Linux -ComputerName $computerName -Credential $cred;
$imgRef = Get-LinuxImage;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
}
else
{
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$imgRef = Get-DefaultCRPWindowsImageOffline;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
}
Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;
if (-not $linux)
{
Assert-AreEqual $p.OSProfile.WindowsConfiguration.ProvisionVMAgent $true;
}
Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer;
Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus;
Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version;
# Virtual Machine
$p = Set-AzureRmVMBootDiagnostics -VM $p -Disable
$v = New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
$vm = Get-AzureRmVM -ResourceGroupName $rgname -VMName $vmname
return $vm
}
function Get-LinuxImage
{
return Create-ComputeVMImageObject 'SUSE' 'SLES' '12-SP1' 'latest';
}

Просмотреть файл

@ -0,0 +1,34 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class AddVhdTests
{
public AddVhdTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact(Skip = "TODO: only works for live mode")]
[Trait(Category.RunType, Category.LiveOnly)]
public void TestAddVhd()
{
ComputeTestController.NewInstance.RunPsTest("Test-AddVhd");
}
}
}

Просмотреть файл

@ -0,0 +1,118 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Test Add Vhd
#>
function Test-AddVhd
{
# Setup
$rgname = Get-ComputeTestResourceName
try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
$storageKey = Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname;
$vhdContainerName = 'vhds';
$path = (get-item -path ".\").FullName;
$csvFile = "upload_VHD.csv";
$csvPath = "..\..\..\..\..\ServiceManagement\Compute\Commands.ServiceManagement.Test\Resources\" + $csvFile;
$testData = Import-Csv $csvPath;
foreach ($testItem in $testData)
{
$vhdLocalPath = 'f:\vhdstore\' + $testItem.vhdName;
$vhdName = GetFileNameWithoutExtension $testItem.vhdName;
$vhdDestUri = [System.String]::Format("{0}{1}/{2}{3}.vhd", $stoaccount.PrimaryEndpoints.Blob, $vhdContainerName, $vhdName, $rgname);
Write-Output ("Start Uploading... : " + $testItem.vhdName);
$vhdUploadContext = Add-AzureRmVhd -ResourceGroupName $rgname -Destination $vhdDestUri -LocalFilePath $vhdLocalPath -NumberOfUploaderThreads 1;
Wait-Seconds 5;
Write-Output ("Destination Uri :" + $vhdUploadContext.DestinationUri);
Write-Output ("Local File :" + $vhdUploadContext.LocalFilePath.FullName);
Write-Output ("Uploading Ended.");
Assert-NotNull $vhdUploadContext;
Assert-AreEqual $vhdDestUri $vhdUploadContext.DestinationUri;
Assert-AreEqual $vhdLocalPath $vhdUploadContext.LocalFilePath.FullName;
Write-Output ($vhdDestUri);
Write-Output ($storageKey.Key1);
$destBlobHandle = GetBlobHandle $vhdDestUri $storageKey.Key1;
Assert-True {VerifyMD5hash $destBlobHandle $testItem.md5hash};
$vhdDownloadPath = $vhdLocalPath + "-download.vhd";
$vhdDownloadContext = Save-AzureRmVhd -ResourceGroupName $rgname -SourceUri $vhdDestUri -LocalFilePath $vhdDownloadPath;
Write-Output ("Source :" +$vhdDownloadContext.Source);
Write-Output ("LocalFilePath :" +$vhdDownloadContext.LocalFilePath);
Assert-AreEqual $vhdDestUri $vhdDownloadContext.Source;
Assert-AreEqual $vhdDownloadPath $vhdDownloadContext.LocalFilePath;
$vhdDownloadContext = Save-AzureRmVhd -ResourceGroupName $rgname -SourceUri $vhdDestUri -LocalFilePath $vhdDownloadPath -Overwrite;
Assert-AreEqual $vhdDestUri $vhdDownloadContext.Source;
Assert-AreEqual $vhdDownloadPath $vhdDownloadContext.LocalFilePath;
}
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function GetFileNameWithoutExtension ($fileName)
{
$fileName.Substring(0, $fileName.IndexOf('.'));
}
function GetBlobHandle
{
param([string] $blobString, [string] $storageKey)
$blobPath = [Microsoft.WindowsAzure.Commands.Sync.Download.BlobUri] $null;
[Microsoft.WindowsAzure.Commands.Sync.Download.BlobUri]::TryParseUri($blobString, [REF]$blobPath);
$blob = [Microsoft.WindowsAzure.Commands.Sync.Download.BlobHandle]::new($blobPath, $storageKey);
return [Microsoft.WindowsAzure.Commands.Sync.Download.BlobHandle] $blob;
}
function VerifyMD5hash
{
param([System.Object] $blobHandle, [string] $md5hash)
$blobMd5 = $blobHandle.Blob.Properties.ContentMD5;
Write-Output ("MD5 hash of the local file: " + $md5hash);
if ([System.String]::IsNullOrEmpty($blobMd5))
{
Write-Output ("The blob does not have MD5 value!!!");
return $false;
}
else
{
Write-Output ("MD5 hash of blob, "+ $blobHandle.Blob.Uri.ToString() + ", is "+ $blobMd5);
return $blobMd5.Equals($md5hash);
}
}

Просмотреть файл

@ -0,0 +1,34 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class AvailabilitySetTests
{
public AvailabilitySetTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAvailabilitySet()
{
ComputeTestController.NewInstance.RunPsTest("Test-AvailabilitySet");
}
}
}

Просмотреть файл

@ -0,0 +1,76 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Test Availability Set
#>
function Test-AvailabilitySet
{
# Setup
$rgname = Get-ComputeTestResourceName
try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
$asetName = 'avs' + $rgname;
$nonDefaultUD = 2;
$nonDefaultFD = 3;
New-AzureRmAvailabilitySet -ResourceGroupName $rgname -Name $asetName -Location $loc -PlatformUpdateDomainCount $nonDefaultUD -PlatformFaultDomainCount $nonDefaultFD -Sku 'Classic';
$asets = Get-AzureRmAvailabilitySet -ResourceGroupName $rgname;
Assert-NotNull $asets;
Assert-AreEqual $asetName $asets[0].Name;
$aset = Get-AzureRmAvailabilitySet -ResourceGroupName $rgname -Name $asetName;
Assert-NotNull $aset;
Assert-AreEqual $aset.Name $asetName;
Assert-AreEqual $nonDefaultUD $aset.PlatformUpdateDomainCount;
Assert-AreEqual $nonDefaultFD $aset.PlatformFaultDomainCount;
Assert-False {$aset.Managed};
Assert-AreEqual 'Classic' $aset.Sku;
$aset | Update-AzureRmAvailabilitySet -Managed;
$aset = Get-AzureRmAvailabilitySet -ResourceGroupName $rgname -Name $asetName;
Assert-NotNull $aset;
Assert-AreEqual $aset.Name $asetName;
Assert-AreEqual $nonDefaultUD $aset.PlatformUpdateDomainCount;
Assert-AreEqual $nonDefaultFD $aset.PlatformFaultDomainCount;
Assert-AreEqual 'Aligned' $aset.Sku;
$aset | Update-AzureRmAvailabilitySet -Sku 'Aligned';
$aset = Get-AzureRmAvailabilitySet -ResourceGroupName $rgname -Name $asetName;
Assert-NotNull $aset;
Assert-AreEqual $aset.Name $asetName;
Assert-AreEqual $nonDefaultUD $aset.PlatformUpdateDomainCount;
Assert-AreEqual $nonDefaultFD $aset.PlatformFaultDomainCount;
Assert-AreEqual 'Aligned' $aset.Sku;
Remove-AzureRmAvailabilitySet -ResourceGroupName $rgname -Name $asetName -Force;
$asets = Get-AzureRmAvailabilitySet -ResourceGroupName $rgname;
Assert-AreEqual $asets $null;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,34 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class ChefExtensionTests
{
public ChefExtensionTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetChefExtensionBasic()
{
ComputeTestController.NewInstance.RunPsTest("Test-SetChefExtensionBasic");
}
}
}

Просмотреть файл

@ -0,0 +1,110 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
#
# ChefExtensionTests.ps1
#
<#
.SYNOPSIS
Test the usage of the Set virtual machine chef extension command
#>
function Test-SetChefExtensionBasic
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
$TestOutputRoot = [System.AppDomain]::CurrentDomain.BaseDirectory;
try
{
############ Create Virtual Machine #############
# Common
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# VM Profile & Hardware
$vmsize = 'Standard_A2';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
# Storage Account
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
# OS & Image
$user = "localadmin";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$p = Set-AzureRmVMSourceImage -VM $p -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
############ Created Virtual Machine #############
############ Test Chef Extension #################
$version = "1210.12"
$client_rb = "$TestOutputRoot\Templates\client.rb";
$validationPemFile = "$TestOutputRoot\Templates\tstorgnztn-validator.pem";
# Set Chef extension
Set-AzureRmVMChefExtension -ResourceGroupName $rgname -VMName $vmname -TypeHandlerVersion $version -ClientRb $client_rb -ValidationPem $validationPemFile -Windows
$extension = Get-AzureRmVMChefExtension -ResourceGroupName $rgname -VMName $vmname -Windows
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Chef.Bootstrap.WindowsAzure'
Assert-AreEqual $extension.ExtensionType 'ChefClient'
Assert-AreEqual $extension.Name 'ChefClient'
# Test Remove command.
Remove-AzureRmVMChefExtension -ResourceGroupName $rgname -VMName $vmname -Windows
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,63 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class ComputeCloudExceptionTests
{
public ComputeCloudExceptionTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RunComputeCloudExceptionTests()
{
// Message Only
var ex1 = new Rest.Azure.CloudException("Test1");
var cx1 = new ComputeCloudException(ex1);
Assert.True(string.Equals(cx1.Message, ex1.Message));
Assert.True(cx1.InnerException is Rest.Azure.CloudException);
Assert.True(string.Equals(cx1.InnerException.Message, ex1.Message));
// Message + Inner Exception
var ex2 = new Rest.Azure.CloudException("Test2", ex1);
var cx2 = new ComputeCloudException(ex2);
Assert.True(string.Equals(cx2.Message, ex2.Message));
Assert.True(cx2.InnerException is Rest.Azure.CloudException);
Assert.True(string.Equals(cx2.InnerException.Message, ex2.Message));
// Empty Message
var ex3 = new Rest.Azure.CloudException(string.Empty);
var cx3 = new ComputeCloudException(ex3);
Assert.True(string.IsNullOrEmpty(cx3.Message));
Assert.True(cx3.InnerException is Rest.Azure.CloudException);
Assert.True(string.IsNullOrEmpty(cx3.InnerException.Message));
// Default message is used, if 'null' passed to the constructor.
var ex4 = new Rest.Azure.CloudException(null);
var cx4 = new ComputeCloudException(ex4);
Assert.True(!string.IsNullOrEmpty(cx4.Message));
Assert.True(cx4.InnerException is Rest.Azure.CloudException);
Assert.True(!string.IsNullOrEmpty(cx4.InnerException.Message));
ComputeTestController.NewInstance.RunPsTest("Run-ComputeCloudExceptionTests");
}
}
}

Просмотреть файл

@ -0,0 +1,36 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
function Run-ComputeCloudExceptionTests
{
# Setup
$rgname = Get-ComputeTestResourceName
try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
$compare = "*Resource*not found*OperationID : *";
Assert-ThrowsLike { $s1 = Get-AzureRmVM -ResourceGroupName $rgname -Name 'test' } $compare;
Assert-ThrowsLike { $s2 = Get-AzureRmVM -ResourceGroupName 'foo' -Name 'bar' } $compare;
Assert-ThrowsLike { $s3 = Get-AzureRmAvailabilitySet -ResourceGroupName $rgname -Name 'test' } $compare;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,600 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Gets valid resource name for compute test
#>
function Get-ComputeTestResourceName
{
$stack = Get-PSCallStack
$testName = $null;
foreach ($frame in $stack)
{
if ($frame.Command.StartsWith("Test-", "CurrentCultureIgnoreCase"))
{
$testName = $frame.Command;
}
}
$oldErrorActionPreferenceValue = $ErrorActionPreference;
$ErrorActionPreference = "SilentlyContinue";
try
{
$assetName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetAssetName($testName, "crptestps");
}
catch
{
if (($Error.Count -gt 0) -and ($Error[0].Exception.Message -like '*Unable to find type*'))
{
$assetName = Get-RandomItemName;
}
else
{
throw;
}
}
finally
{
$ErrorActionPreference = $oldErrorActionPreferenceValue;
}
return $assetName
}
<#
.SYNOPSIS
Gets test mode - 'Record' or 'Playback'
#>
function Get-ComputeTestMode
{
$oldErrorActionPreferenceValue = $ErrorActionPreference;
$ErrorActionPreference = "SilentlyContinue";
try
{
$testMode = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode;
$testMode = $testMode.ToString();
}
catch
{
if (($Error.Count -gt 0) -and ($Error[0].Exception.Message -like '*Unable to find type*'))
{
$testMode = 'Record';
}
else
{
throw;
}
}
finally
{
$ErrorActionPreference = $oldErrorActionPreferenceValue;
}
return $testMode;
}
# Get Storage Endpoint Suffix
function Get-StorageEndpointSuffix
{
return $env:STORAGEENDPOINTSUFFIX;
}
# Get Default Storage Endpoint Suffix
function Get-DefaultStorageEndpointSuffix
{
$storageEndpointSuffix = Get-StorageEndpointSuffix;
if ($storageEndpointSuffix -eq '' -or $storageEndpointSuffix -eq $null)
{
$storageEndpointSuffix = 'local.azurestack.external';
}
return $storageEndpointSuffix;
}
# Get Compute Test Location
function Get-ComputeTestLocation
{
return $env:AZURE_COMPUTE_TEST_LOCATION;
}
# Get Compute Default Test Location
function Get-ComputeDefaultLocation
{
$test_location = Get-ComputeTestLocation;
if ($test_location -eq '' -or $test_location -eq $null)
{
$test_location = 'westus';
}
return $test_location;
}
# Create a new virtual machine with other necessary resources configured
function Create-VirtualMachine($rgname, $vmname, $loc)
{
# Initialize parameters
$rgname = if ([string]::IsNullOrEmpty($rgname)) { Get-ComputeTestResourceName } else { $rgname }
$vmname = if ([string]::IsNullOrEmpty($vmname)) { 'vm' + $rgname } else { $vmname }
$loc = if ([string]::IsNullOrEmpty($loc)) { Get-ComputeVMLocation } else { $loc }
$storageEndpointSuffix = Get-DefaultStorageEndpointSuffix;
# Common
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# VM Profile & Hardware
$vmsize = 'Standard_A2';
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
#$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
$stokey = (Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname).Key1;
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.$storageEndpointSuffix/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.$storageEndpointSuffix/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.$storageEndpointSuffix/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.$storageEndpointSuffix/test/data3.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';
Assert-AreEqual $p.StorageProfile.OsDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OsDisk.Name $osDiskName;
Assert-AreEqual $p.StorageProfile.OsDisk.Vhd.Uri $osDiskVhdUri;
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;
# OS & Image
$user = "Foo12";
$password = 'BaR@123' + $rgname;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.$storageEndpointSuffix/test";
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$imgRef = Get-DefaultCRPWindowsImageOffline;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;
Assert-AreEqual $p.OSProfile.WindowsConfiguration.ProvisionVMAgent $true;
Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer;
Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus;
Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version;
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
$vm = Get-AzureRmVM -ResourceGroupName $rgname -VMName $vmname
return $vm
}
# Cleans the created resource group
function Clean-ResourceGroup($rgname)
{
Remove-AzureRmResourceGroup -Name $rgname -Force;
}
# Get Compute Test Tag
function Get-ComputeTestTag
{
param ([string] $tagname)
return @{ Name = $tagname; Value = (Get-Date).ToUniversalTime().ToString("u") };
}
######################
#
# Retry the given code block until it succeeds or times out.
#
# param [ScriptBlock] $script : The code to test
# param [int] $times : The times of running the code
# param [string] $message : The text of the exception that should be thrown
#######################
function Retry-IfException
{
param([ScriptBlock] $script, [int] $times = 30, [string] $message = "*")
if ($times -le 0)
{
throw 'Retry time(s) should not be equal to or less than 0.';
}
$oldErrorActionPreferenceValue = $ErrorActionPreference;
$ErrorActionPreference = "SilentlyContinue";
$iter = 0;
$succeeded = $false;
while (($iter -lt $times) -and (-not $succeeded))
{
$iter += 1;
&$script;
if ($Error.Count -gt 0)
{
$actualMessage = $Error[0].Exception.Message;
Write-Output ("Caught exception: '$actualMessage'");
if (-not ($actualMessage -like $message))
{
$ErrorActionPreference = $oldErrorActionPreferenceValue;
throw "Expected exception not received: '$message' the actual message is '$actualMessage'";
}
$Error.Clear();
Wait-Seconds 10;
continue;
}
$succeeded = $true;
}
$ErrorActionPreference = $oldErrorActionPreferenceValue;
}
<#
.SYNOPSIS
Gets random resource name
#>
function Get-RandomItemName
{
param([string] $prefix = "crptestps")
if ($prefix -eq $null -or $prefix -eq '')
{
$prefix = "crptestps";
}
$str = $prefix + ((Get-Random) % 10000);
return $str;
}
<#
.SYNOPSIS
Gets default VM size string
#>
function Get-DefaultVMSize
{
param([string] $location = "westus")
$location = Get-ComputeVMLocation;
$vmSizes = Get-AzureRmVMSize -Location $location | where { $_.NumberOfCores -ge 4 -and $_.MaxDataDiskCount -ge 8 };
foreach ($sz in $vmSizes)
{
if ($sz.Name -eq 'Standard_A3')
{
return $sz.Name;
}
}
return $vmSizes[0].Name;
}
<#
.SYNOPSIS
Gets default RDFE Image
#>
function Get-DefaultRDFEImage
{
param([string] $loca = "East Asia", [string] $query = '*Windows*Data*Center*')
$d = (Azure\Get-AzureRmVMImage | where {$_.ImageName -like $query -and ($_.Location -like "*;$loca;*" -or $_.Location -like "$loca;*" -or $_.Location -like "*;$loca" -or $_.Location -eq "$loca")});
if ($d -eq $null)
{
return $null;
}
else
{
return $d[-1].ImageName;
}
}
<#
.SYNOPSIS
Gets default storage type string
#>
function Get-DefaultStorageType
{
return 'Standard_LRS';
}
<#
.SYNOPSIS
Gets default CRP Image
#>
function Get-DefaultCRPImage
{
param([string] $loc = "westus", [string] $query = '*Microsoft*Windows*Server')
$loc = Get-ComputeVMLocation;
$result = (Get-AzureRmVMImagePublisher -Location $loc) | select -ExpandProperty PublisherName | where { $_ -like $query };
if ($result.Count -eq 1)
{
$defaultPublisher = $result;
}
else
{
$defaultPublisher = $result[0];
}
$result = (Get-AzureRmVMImageOffer -Location $loc -PublisherName $defaultPublisher) | select -ExpandProperty Offer | where { $_ -like '*Windows*' };
if ($result.Count -eq 1)
{
$defaultOffer = $result;
}
else
{
$defaultOffer = $result[0];
}
$result = (Get-AzureRmVMImageSku -Location $loc -PublisherName $defaultPublisher -Offer $defaultOffer) | select -ExpandProperty Skus;
if ($result.Count -eq 1)
{
$defaultSku = $result;
}
else
{
$defaultSku = $result[0];
}
$result = (Get-AzureRmVMImage -Location $loc -Offer $defaultOffer -PublisherName $defaultPublisher -Skus $defaultSku) | select -ExpandProperty Version;
if ($result.Count -eq 1)
{
$defaultVersion = $result;
}
else
{
$defaultVersion = $result[0];
}
$vmimg = Get-AzureRmVMImage -Location $loc -Offer $defaultOffer -PublisherName $defaultPublisher -Skus $defaultSku -Version $defaultVersion;
return $vmimg;
}
# Create Image Object
function Create-ComputeVMImageObject
{
param ([string] $publisherName, [string] $offer, [string] $skus, [string] $version)
$img = New-Object -TypeName 'Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineImage';
$img.PublisherName = $publisherName;
$img.Offer = $offer;
$img.Skus = $skus;
$img.Version = $version;
return $img;
}
# Get Default CRP Windows Image Object Offline
function Get-DefaultCRPWindowsImageOffline
{
return Create-ComputeVMImageObject 'MicrosoftWindowsServer' 'WindowsServer' '2012-R2-Datacenter' '1.0.0';
}
# Get Default CRP Linux Image Object Offline
function Get-DefaultCRPLinuxImageOffline
{
return Create-ComputeVMImageObject 'Canonical' 'UbuntuServer' '14.04.3-LTS' '1.0.0';
}
<#
.SYNOPSIS
Gets VMM Images
#>
function Get-MarketplaceImage
{
param([string] $location = "westus", [string] $pubFilter = '*', [string] $offerFilter = '*')
$location = Get-ComputeVMLocation;
$pubFilter = 'MicrosoftWindowsServer'
$offerFilter = 'WindowsServer'
$imgs = Get-AzureRmVMImagePublisher -Location $location | where { $_.PublisherName -like $pubFilter } | Get-AzureRmVMImageOffer | where { $_.Offer -like $offerFilter } | Get-AzureRmVMImageSku | Get-AzureRmVMImage | Get-AzureRmVMImage | where { $_.PurchasePlan -ne $null };
return $imgs;
}
<#
.SYNOPSIS
Gets default VM config object
#>
function Get-DefaultVMConfig
{
param([string] $location = "westus")
$location = Get-ComputeVMLocation;
# VM Profile & Hardware
$vmsize = Get-DefaultVMSize $location;
$vmname = Get-RandomItemName 'crptestps';
$vm = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
return $vm;
}
# Assert Output Contains
function Assert-OutputContains
{
param([string] $cmd, [string[]] $sstr)
$st = Write-Verbose ('Running Command : ' + $cmd);
$output = Invoke-Expression $cmd | Out-String;
$max_output_len = 1500;
if ($output.Length -gt $max_output_len)
{
# Truncate Long Output in Logs
$st = Write-Verbose ('Output String : ' + $output.Substring(0, $max_output_len) + '...');
}
else
{
$st = Write-Verbose ('Output String : ' + $output);
}
$index = 1;
foreach ($str in $sstr)
{
$st = Write-Verbose ('Search String ' + $index++ + " : `'" + $str + "`'");
Assert-True { $output.Contains($str) }
$st = Write-Verbose "Found.";
}
}
# Create a SAS Uri
function Get-SasUri
{
param ([string] $storageAccount, [string] $storageKey, [string] $container, [string] $file, [TimeSpan] $duration, [Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions] $type)
$storageEndpointSuffix = Get-DefaultStorageEndpointSuffix;
$uri = [string]::Format("https://{0}.blob.$storageEndpointSuffix/{1}/{2}", $storageAccount, $container, $file);
$destUri = New-Object -TypeName System.Uri($uri);
$cred = New-Object -TypeName Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($storageAccount, $storageKey);
$destBlob = New-Object -TypeName Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob($destUri, $cred);
$policy = New-Object Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy;
$policy.Permissions = $type;
$policy.SharedAccessExpiryTime = [DateTime]::UtcNow.Add($duration);
$uri += $destBlob.GetSharedAccessSignature($policy);
return $uri;
}
# Get a Location according to resource provider.
function Get-ResourceProviderLocation
{
param ([string] $provider)
$namespace = $provider.Split("/")[0];
if($provider.Contains("/"))
{
$type = $provider.Substring($namespace.Length + 1);
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type};
if ($location -eq $null)
{
return "westus";
}
else
{
return $location.Locations[0];
}
}
return "westus";
}
function Get-ComputeVMLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines";
}
function Get-ComputeAvailabilitySetLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/availabilitySets";
}
function Get-ComputeVMExtensionLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines/extensions";
}
function Get-ComputeVMDiagnosticSettingLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines/diagnosticSettings";
}
function Get-ComputeVMMetricDefinitionLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines/metricDefinitions";
}
function Get-ComputeOperationLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/locations/operations";
}
function Get-ComputeVMSizeLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/locations/vmSizes";
}
function Get-ComputeUsageLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/locations/usages";
}
function Get-ComputePublisherLocation
{
Get-ResourceProviderLocation "Microsoft.Compute/locations/publishers";
}
function Get-SubscriptionIdFromResourceGroup
{
param ([string] $rgname)
$rg = Get-AzureRmResourceGroup -ResourceGroupName $rgname;
$rgid = $rg.ResourceId;
# ResouceId is a form of "/subscriptions/<subId>/resourceGroups/<resourgGroupName>"
# So return the second part to get subscription Id
$first = $rgid.IndexOf('/', 1);
$last = $rgid.IndexOf('/', $first + 1);
return $rgid.Substring($first + 1, $last - $first - 1);
}

Просмотреть файл

@ -0,0 +1,41 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public partial class ContainerServiceTests
{
public ContainerServiceTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestContainerService()
{
ComputeTestController.NewInstance.RunPsTest("Test-ContainerService");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestContainerServiceUpdate()
{
ComputeTestController.NewInstance.RunPsTest("Test-ContainerServiceUpdate");
}
}
}

Просмотреть файл

@ -0,0 +1,155 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Test Container Service
#>
function Test-ContainerService
{
# Setup
$rgname = Get-ComputeTestResourceName
try
{
# Common
$loc = 'australiasoutheast';
New-AzureRMResourceGroup -Name $rgname -Location $loc -Force;
$csName = 'cs' + $rgname;
$masterDnsPrefixName = 'master' + $rgname;
$agentPoolDnsPrefixName = 'ap' + $rgname;
$agentPoolProfileName = 'AgentPool1';
$vmSize = 'Standard_A1';
$orchestratorType = 'DCOS';
$adminUserName = 'acslinuxadmin';
$sshPublicKey =
"MIIDszCCApugAwIBAgIJALBV9YJCF/tAMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV" +
"BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX" +
"aWRnaXRzIFB0eSBMdGQwHhcNMTUwMzIyMjI1NDQ5WhcNMTYwMzIxMjI1NDQ5WjBF" +
"MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50" +
"ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIB" +
"CAKCAQEAxDC+OfmB+tQ+P1MLmuuW2hJLdcK8m4DLgAk5l8bQDNBcVezt+bt/ZFMs" +
"CHBhfTZG9O9yqMn8IRUh7/7jfQm6DmXCgtxj/uFiwT+F3out5uWvMV9SjFYvu9kJ" +
"NXiDC2u3l4lHV8eHde6SbKiZB9Jji9FYQV4YiWrBa91j9I3hZzbTL0UCiJ+1PPoL" +
"Rx/T1s9KT5Wn8m/z2EDrHWpetYu45OA7nzyIFOyQup5oWadWNnpk6HkCGutl9t9b" +
"cLdjXjXPm9wcy1yxIB3Dj/Y8Hnulr80GJlUtUboDm8TExGc4YaPJxdn0u5igo5gZ" +
"c6qnqH/BMd1nsyICx6AZnKBXBycoSQIBI6OBpzCBpDAdBgNVHQ4EFgQUzWhrCCDs" +
"ClANCGlKZ64rHp2BDn0wdQYDVR0jBG4wbIAUzWhrCCDsClANCGlKZ64rHp2BDn2h" +
"SaRHMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQK" +
"ExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGSCCQCwVfWCQhf7QDAMBgNVHRMEBTAD" +
"AQH/MA0GCSqGSIb3DQEBBQUAA4IBAQCUaJnX0aBzwBkbJrBS5YvkZnNKLdc4oHgC" +
"/Nsr/9pwXzFYYXkdqpTw2nygH0C0WuPVVrG3Y3EGx/UIGDtLbwMvZJhQN9mZH3oX" +
"+c3HGqBnXGuDRrtsfsK1ywAofx9amZfKNk/04/Rt3POdbyD1/AOADw2zMokbIapX" +
"+nMDUtD/Tew9+0qU9+dcFMrFE1N4utlrFHlrLFbiCA/eSegP6gOeu9mqZv7UHIz2" +
"oe6IQTw7zJF7xuBIzTYwjOCM197GKW7xc4GU4JZIN+faZ7njl/fxfUNdlqvgZUUn" +
"kfdrzU3PZPl0w9NuncgEje/PZ+YtZvIsnH7MLSPeIGNQwW6V2kc8";
$container = New-AzureRmContainerServiceConfig -Location $loc -OrchestratorType $orchestratorType `
-MasterDnsPrefix $masterDnsPrefixName -AdminUsername $adminUserName -SshPublicKey $sshPublicKey `
| Add-AzureRmContainerServiceAgentPoolProfile -Name $agentPoolProfileName -VmSize $vmSize -DnsPrefix $agentPoolDnsPrefixName -Count 1 `
| New-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
$cs = Get-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
$output = $cs | Out-String;
Assert-True { $output.Contains("AgentPoolProfiles") };
$cslist = Get-AzureRmContainerService -ResourceGroupName $rgname;
$output = $cslist | Out-String;
Assert-False { $output.Contains("AgentPoolProfiles") };
$st = Remove-AzureRmContainerService -ResourceGroupName $rgname -Name $csName -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
<#
.SYNOPSIS
Test Container Service Update
#>
function Test-ContainerServiceUpdate
{
# Setup
$rgname = Get-ComputeTestResourceName
try
{
# Common
$loc = 'australiasoutheast';
New-AzureRMResourceGroup -Name $rgname -Location $loc -Force;
$csName = 'cs' + $rgname;
$masterDnsPrefixName = 'master' + $rgname;
$agentPoolDnsPrefixName = 'ap' + $rgname;
$agentPoolProfileName = 'AgentPool1';
$vmSize = 'Standard_A1';
$orchestratorType = 'DCOS';
$adminUserName = 'acslinuxadmin';
$sshPublicKey =
"MIIDszCCApugAwIBAgIJALBV9YJCF/tAMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV" +
"BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX" +
"aWRnaXRzIFB0eSBMdGQwHhcNMTUwMzIyMjI1NDQ5WhcNMTYwMzIxMjI1NDQ5WjBF" +
"MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50" +
"ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIB" +
"CAKCAQEAxDC+OfmB+tQ+P1MLmuuW2hJLdcK8m4DLgAk5l8bQDNBcVezt+bt/ZFMs" +
"CHBhfTZG9O9yqMn8IRUh7/7jfQm6DmXCgtxj/uFiwT+F3out5uWvMV9SjFYvu9kJ" +
"NXiDC2u3l4lHV8eHde6SbKiZB9Jji9FYQV4YiWrBa91j9I3hZzbTL0UCiJ+1PPoL" +
"Rx/T1s9KT5Wn8m/z2EDrHWpetYu45OA7nzyIFOyQup5oWadWNnpk6HkCGutl9t9b" +
"cLdjXjXPm9wcy1yxIB3Dj/Y8Hnulr80GJlUtUboDm8TExGc4YaPJxdn0u5igo5gZ" +
"c6qnqH/BMd1nsyICx6AZnKBXBycoSQIBI6OBpzCBpDAdBgNVHQ4EFgQUzWhrCCDs" +
"ClANCGlKZ64rHp2BDn0wdQYDVR0jBG4wbIAUzWhrCCDsClANCGlKZ64rHp2BDn2h" +
"SaRHMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQK" +
"ExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGSCCQCwVfWCQhf7QDAMBgNVHRMEBTAD" +
"AQH/MA0GCSqGSIb3DQEBBQUAA4IBAQCUaJnX0aBzwBkbJrBS5YvkZnNKLdc4oHgC" +
"/Nsr/9pwXzFYYXkdqpTw2nygH0C0WuPVVrG3Y3EGx/UIGDtLbwMvZJhQN9mZH3oX" +
"+c3HGqBnXGuDRrtsfsK1ywAofx9amZfKNk/04/Rt3POdbyD1/AOADw2zMokbIapX" +
"+nMDUtD/Tew9+0qU9+dcFMrFE1N4utlrFHlrLFbiCA/eSegP6gOeu9mqZv7UHIz2" +
"oe6IQTw7zJF7xuBIzTYwjOCM197GKW7xc4GU4JZIN+faZ7njl/fxfUNdlqvgZUUn" +
"kfdrzU3PZPl0w9NuncgEje/PZ+YtZvIsnH7MLSPeIGNQwW6V2kc8";
$container = New-AzureRmContainerServiceConfig -Location $loc `
-OrchestratorType $orchestratorType `
-MasterDnsPrefix $masterDnsPrefixName `
-MasterCount 1 `
-AdminUsername $adminUserName `
-SshPublicKey $sshPublicKey `
| Add-AzureRmContainerServiceAgentPoolProfile -Name $agentPoolProfileName `
-VmSize $vmSize `
-DnsPrefix $agentPoolDnsPrefixName `
-Count 1 `
| New-AzureRmContainerService -ResourceGroupName $rgname -Name $csName;
Get-AzureRmContainerService -ResourceGroupName $rgname -Name $csName `
| Remove-AzureRmContainerServiceAgentPoolProfile -Name $agentPoolProfileName `
| Add-AzureRmContainerServiceAgentPoolProfile -Name $agentPoolProfileName `
-VmSize $vmSize `
-DnsPrefix $agentPoolDnsPrefixName `
-Count 2 `
| Update-AzureRmContainerService;
$st = Get-AzureRmContainerService -ResourceGroupName $rgname -Name $csName | Remove-AzureRmContainerService -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,29 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class DiagnosticsExtensionTests
{
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDiagnosticsExtensionCantListSepcifyStorageAccountKey()
{
ComputeTestController.NewInstance.RunPsTest("Test-DiagnosticsExtensionCantListSepcifyStorageAccountKey");
}
}
}

Просмотреть файл

@ -0,0 +1,186 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Test the basic usage of the Set/Get/Remove virtual machine diagnostics extension command
#>
function Test-DiagnosticsExtensionBasic
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-VirtualMachine -rgname $rgname -loc $loc
$vmname = $vm.Name
# This is the storage name defined in config file
$storagename = 'definedinconfigstorage'
$storagetype = 'Standard_LRS'
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
# If diagnostics extension already exist, remove it
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
if ($extension) {
Remove-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
# Test Set and Get command. It should use the storage account defined in configuration file
Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath '.\ConfigFiles\DiagnosticsExtensionConfig.xml'
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.Azure.Diagnostics'
Assert-AreEqual $extension.ExtensionType 'IaaSDiagnostics'
Assert-AreEqual $extension.Name 'Microsoft.Insights.VMDiagnosticsSettings'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-AreEqual $settings.storageAccount $storagename
# Test Remove command.
Remove-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
<#
.SYNOPSIS
Test specifying storage account name in command line.
The diagnostic extension should use this name instead of the one defined in config file.
#>
function Test-DiagnosticsExtensionSepcifyStorageAccountName
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-VirtualMachine -rgname $rgname -loc $loc
$vmname = $vm.Name
# This storage name will be used in command line directly when set diagnostics extension
$storagename = 'definedincommandline'
$storagetype = 'Standard_LRS'
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
# If diagnostics extension already exist, remove it
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
if ($extension) {
Remove-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath '.\ConfigFiles\DiagnosticsExtensionConfig.xml' -StorageAccountName $storagename
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.Publisher 'Microsoft.Azure.Diagnostics'
Assert-AreEqual $extension.ExtensionType 'IaaSDiagnostics'
Assert-AreEqual $extension.Name 'Microsoft.Insights.VMDiagnosticsSettings'
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-AreEqual $settings.storageAccount $storagename
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
<#
.SYNOPSIS
Test the case if we can't list the storage account key, the command should fail.
#>
function Test-DiagnosticsExtensionCantListSepcifyStorageAccountKey
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-VirtualMachine -rgname $rgname -loc $loc
$vmname = $vm.Name
# If diagnostics extension already exist, remove it
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
if ($extension) {
Remove-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
# Get a random storage account name, which we can't list the key
$storagename = 'notexiststorage'
Assert-ThrowsContains `
{ Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath '.\ConfigFiles\DiagnosticsExtensionConfig.xml' -StorageAccountName $storagename } `
'Storage account key'
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
<#
.SYNOPSIS
Test that we support config file in json format
#>
function Test-DiagnosticsExtensionSupportJsonConfig
{
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Setup
$vm = Create-VirtualMachine -rgname $rgname -loc $loc
$vmname = $vm.Name
$storagename = $vmname + "storage"
$storagetype = 'Standard_LRS'
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
# If diagnostics extension already exist, remove it
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
if ($extension) {
Remove-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-Null $extension
}
Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath '.\ConfigFiles\DiagnosticsExtensionConfig.json' -StorageAccountName $storagename
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
$settings = $extension.PublicSettings | ConvertFrom-Json
Assert-AreEqual $settings.storageAccount $storagename
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,40 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class DiskRPTests
{
public DiskRPTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
public void TestDisk()
{
ComputeTestController.NewInstance.RunPsTest("Test-Disk");
}
[Fact]
public void TestSnapshot()
{
ComputeTestController.NewInstance.RunPsTest("Test-Snapshot");
}
}
}

Просмотреть файл

@ -0,0 +1,147 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Testing disk and snapshot commands
#>
function Test-Disk
{
# Setup
$rgname = Get-ComputeTestResourceName;
$diskname = 'disk' + $rgname;
try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
$subId = Get-SubscriptionIdFromResourceGroup $rgname;
$mockkey = 'https://myvault.vault-int.azure-int.net/secrets/123/';
$mocksourcevault = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.KeyVault/vaults/TestVault123';
$access = 'Read';
# Config create test
$diskconfig = New-AzureRmDiskConfig -Location $loc -DiskSizeGB 5 -AccountType StandardLRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
# Encryption test
$diskconfig = Set-AzureRmDiskDiskEncryptionKey -Disk $diskconfig -SecretUrl $mockkey -SourceVaultId $mocksourcevault;
$diskconfig = Set-AzureRmDiskKeyEncryptionKey -Disk $diskconfig -KeyUrl $mockkey -SourceVaultId $mocksourcevault;
Assert-AreEqual $mockkey $diskconfig.EncryptionSettings.DiskEncryptionKey.SecretUrl;
Assert-AreEqual $mocksourcevault $diskconfig.EncryptionSettings.DiskEncryptionKey.SourceVault.Id;
Assert-AreEqual $mockkey $diskconfig.EncryptionSettings.KeyEncryptionKey.KeyUrl;
Assert-AreEqual $mocksourcevault $diskconfig.EncryptionSettings.KeyEncryptionKey.SourceVault.Id;
# Image test
$mockimage = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.Compute/images/TestImage123';
$diskconfig = Set-AzureRmDiskImageReference -Disk $diskconfig -Id $mockimage -Lun 0;
Assert-AreEqual $mockimage $diskconfig.CreationData.ImageReference.Id;
Assert-AreEqual 0 $diskconfig.CreationData.ImageReference.Lun;
$diskconfig.EncryptionSettings.Enabled = $false;
$diskconfig.EncryptionSettings.DiskEncryptionKey = $null;
$diskconfig.EncryptionSettings.KeyEncryptionKey = $null;
$diskconfig.CreationData.ImageReference = $null;
New-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname -Disk $diskconfig;
# Get disk test
$disk = Get-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname;
Assert-AreEqual 5 $disk.DiskSizeGB;
Assert-AreEqual StandardLRS $disk.Sku.Name;
Assert-AreEqual Windows $disk.OsType;
Assert-AreEqual Empty $disk.CreationData.CreateOption;
Assert-AreEqual $false $disk.EncryptionSettings.Enabled;
# Grant access test
Grant-AzureRmDiskAccess -ResourceGroupName $rgname -DiskName $diskname -Access $access -DurationInSecond 5;
Revoke-AzureRmDiskAccess -ResourceGroupName $rgname -DiskName $diskname;
# Config update test
$updateconfig = New-AzureRmDiskUpdateConfig -DiskSizeGB 10 -AccountType PremiumLRS -OsType Windows;
Update-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname -DiskUpdate $updateconfig;
# Remove test
Remove-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-Snapshot
{
# Setup
$rgname = Get-ComputeTestResourceName;
$snapshotname = 'snapshot' + $rgname;
try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
$subId = Get-SubscriptionIdFromResourceGroup $rgname;
$mockkey = 'https://myvault.vault-int.azure-int.net/secrets/123/';
$mocksourcevault = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.KeyVault/vaults/TestVault123';
$access = 'Read';
# Config and create test
$snapshotconfig = New-AzureRmSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType StandardLRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
# Encryption test
$snapshotconfig = Set-AzureRmSnapshotDiskEncryptionKey -Snapshot $snapshotconfig -SecretUrl $mockkey -SourceVaultId $mocksourcevault;
$snapshotconfig = Set-AzureRmSnapshotKeyEncryptionKey -Snapshot $snapshotconfig -KeyUrl $mockkey -SourceVaultId $mocksourcevault;
Assert-AreEqual $mockkey $snapshotconfig.EncryptionSettings.DiskEncryptionKey.SecretUrl;
Assert-AreEqual $mocksourcevault $snapshotconfig.EncryptionSettings.DiskEncryptionKey.SourceVault.Id;
Assert-AreEqual $mockkey $snapshotconfig.EncryptionSettings.KeyEncryptionKey.KeyUrl;
Assert-AreEqual $mocksourcevault $snapshotconfig.EncryptionSettings.KeyEncryptionKey.SourceVault.Id;
# Image test
$mockimage = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.Compute/images/TestImage123';
$snapshotconfig = Set-AzureRmSnapshotImageReference -Snapshot $snapshotconfig -Id $mockimage -Lun 0;
Assert-AreEqual $mockimage $snapshotconfig.CreationData.ImageReference.Id;
Assert-AreEqual 0 $snapshotconfig.CreationData.ImageReference.Lun;
$snapshotconfig.EncryptionSettings.Enabled = $false;
$snapshotconfig.EncryptionSettings.DiskEncryptionKey = $null;
$snapshotconfig.EncryptionSettings.KeyEncryptionKey = $null;
$snapshotconfig.CreationData.ImageReference = $null;
New-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Snapshot $snapshotconfig;
# Get snapshot test
$snapshot = Get-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname;
Assert-AreEqual 5 $snapshot.DiskSizeGB;
Assert-AreEqual StandardLRS $snapshot.Sku.Name;
Assert-AreEqual Windows $snapshot.OsType;
Assert-AreEqual Empty $snapshot.CreationData.CreateOption;
Assert-AreEqual $false $snapshot.EncryptionSettings.Enabled;
# Grant access test
Grant-AzureRmSnapshotAccess -ResourceGroupName $rgname -SnapshotName $snapshotname -Access $access -DurationInSecond 5;
Revoke-AzureRmSnapshotAccess -ResourceGroupName $rgname -SnapshotName $snapshotname;
# Config update test
$updateconfig = New-AzureRmSnapshotUpdateConfig -DiskSizeGB 10 -AccountType PremiumLRS -OsType Windows;
Update-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -SnapshotUpdate $updateconfig;
# Remove test
Remove-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,9 @@
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class DscExtensionTests
{
}
}

Просмотреть файл

@ -0,0 +1,135 @@
<#
.SYNOPSIS
End to end DSC test that tests Get-AzureRmVMDscExtension cmdlet. It does the following:
1) Publishes a configuration to the default storage account using Publish-AzureRmVMDscConfiguration cmdlet
2) Installs the extension by calling Set-AzureRmVMDscExtension cmdlet on a VM.
3) Calls Get-AzureRmVMDscExtensionStatus cmdlet to check the status of the extension installation.
4) Calls Get-AzureRmVMDscExtension cmdlet to get extension details post installation.
#>
function Test-GetAzureRmVMDscExtension
{
Set-StrictMode -Version latest; $ErrorActionPreference = 'Stop'
# Setup
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Common
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
$storageEndpointSuffix = Get-DefaultStorageEndpointSuffix;
# VM Profile & Hardware
$vmsize = 'Standard_A2';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
# Storage Account
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.$storageEndpointSuffix/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.$storageEndpointSuffix/test/data1.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
# OS & Image
$user = "Foo12";
$password = 'BaR@123' + $rgname;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.$storageEndpointSuffix/test";
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$imgRef = Get-DefaultCRPWindowsImageOffline;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
# Test DSC Extension
$version = '2.8';
# Publish DSC Configuration
#TODO: Find a way to mock calls with storage
#$configPath = '.\ScenarioTests\DummyConfig.ps1'
#Publish-AzureRmVMDscConfiguration -ConfigurationPath $configPath -ResourceGroupName $rgname -StorageAccountName $stoname -Force -Verbose
#Install DSC Extension handler
Set-AzureRmVMDscExtension -ResourceGroupName $rgname -VMName $vmname -ArchiveBlobName $null -ArchiveStorageAccountName $stoname -Version $version -Force -Location $loc -AutoUpdate
$extension = Get-AzureRmVMDscExtension -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $extension
Assert-AreEqual $extension.ResourceGroupName $rgname
Assert-AreEqual $extension.Name "Microsoft.Powershell.DSC"
Assert-AreEqual $extension.Publisher "Microsoft.Powershell"
Assert-AreEqual $extension.ExtensionType "DSC"
Assert-AreEqual $extension.TypeHandlerVersion $version
Assert-NotNull $extension.ProvisioningState
$status = Get-AzureRmVMDscExtensionStatus -ResourceGroupName $rgname -VMName $vmname
Assert-NotNull $status
Assert-AreEqual $status.ResourceGroupName $rgname
Assert-AreEqual $status.VmName $vmname
Assert-AreEqual $status.Version $version
Assert-NotNull $status.Status
Assert-NotNull $status.Timestamp
# Remove Extension
Remove-AzureRmVMDscExtension -ResourceGroupName $rgname -VMName $vmname
}
finally
{
# Cleanup
if(Get-AzureRmResourceGroup -Name $rgname -Location $loc)
{
#Remove-AzureRmResourceGroup -Name $rgname -Force;
}
}
}
#helper methods for ARM
function Get-DefaultResourceGroupLocation
{
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
$namespace = "Microsoft.Resources"
$type = "resourceGroups"
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
if ($location -eq $null)
{
return "West US"
} else
{
return $location.Locations[0]
}
}
return "West US"
}

Просмотреть файл

@ -0,0 +1,12 @@
Configuration DummyConfig
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Script dummyscript
{
SetScript = 'Write-Verbose -Verbose "Testing Dummy script!!"'
GetScript = "Test dummyscript"
TestScript = {$false}
}
}

Просмотреть файл

@ -0,0 +1,174 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
# Warning: This code was generated by a tool.
#
# Changes to this file may cause incorrect behavior and will be lost if the
# code is regenerated.
$global:ps_test_tag_name = 'crptestps6050'
function get_vm_config_object
{
param ([string] $rgname, [string] $vmsize)
$st = Write-Verbose "Creating VM Config Object - Start";
$vmname = $rgname + 'vm';
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
$st = Write-Verbose "Creating VM Config Object - End";
return $p;
}
function get_created_storage_account_name
{
param ([string] $loc, [string] $rgname)
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - Start";
$stoname = $rgname + 'sto';
$stotype = 'Standard_GRS';
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - '${stotype}' & '${stoname}'";
$st = New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$st = Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Tags (Get-ComputeTestTag $global:ps_test_tag_name);
$st = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - End";
return $stoname;
}
function create_and_setup_nic_ids
{
param ([string] $loc, [string] $rgname, $vmconfig)
$st = Write-Verbose "Creating and getting NICs for '${loc}' and '${rgname}' - Start";
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ($rgname + 'subnet') -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ($rgname + 'vnet') -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet -Tag (Get-ComputeTestTag $global:ps_test_tag_name);
$vnet = Get-AzureRmVirtualNetwork -Name ($rgname + 'vnet') -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$nic_ids = @($null) * 1;
$nic0 = New-AzureRmNetworkInterface -Force -Name ($rgname + 'nic0') -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -Tag (Get-ComputeTestTag $global:ps_test_tag_name);
$nic_ids[0] = $nic0.Id;
$vmconfig = Add-AzureRmVMNetworkInterface -VM $vmconfig -Id $nic0.Id;
$st = Write-Verbose "Creating and getting NICs for '${loc}' and '${rgname}' - End";
return $nic_ids;
}
function create_and_setup_vm_config_object
{
param ([string] $loc, [string] $rgname, [string] $vmsize)
$st = Write-Verbose "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - Start";
$vmconfig = get_vm_config_object $rgname $vmsize
$user = "Foo12";
$password = $rgname + "BaR#123";
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = $rgname + "cn";
$vmconfig = Set-AzureRmVMOperatingSystem -VM $vmconfig -Windows -ComputerName $computerName -Credential $cred;
$st = Write-Verbose "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - End";
return $vmconfig;
}
function setup_image_and_disks
{
param ([string] $loc, [string] $rgname, [string] $stoname, $vmconfig)
$st = Write-Verbose "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - Start";
$osDiskName = 'osDisk';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$osDiskCaching = 'ReadWrite';
$vmconfig = Set-AzureRmVMOSDisk -VM $vmconfig -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
# Image Reference
$imgRef = Get-DefaultCRPImage -loc $loc;
$vmconfig = ($imgRef | Set-AzureRmVMSourceImage -VM $vmconfig);
# Do not add any data disks
$vmconfig.StorageProfile.DataDisks = $null;
$st = Write-Verbose "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - End";
return $vmconfig;
}
function ps_vm_dynamic_test_func_1_crptestps5352
{
# Setup
$rgname = 'crptestps5352';
try
{
$loc = 'East US 2';
$vmsize = 'Standard_A1';
$st = Write-Verbose "Running Test ps_vm_dynamic_test_func_1_crptestps5352 - Start ${rgname}, ${loc} & ${vmsize}";
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_1_crptestps5352 - Creating Resource Group';
$st = New-AzureRmResourceGroup -Location $loc -Name $rgname -Tag (Get-ComputeTestTag $global:ps_test_tag_name) -Force;
$vmconfig = create_and_setup_vm_config_object $loc $rgname $vmsize;
# Setup Storage Account
$stoname = get_created_storage_account_name $loc $rgname;
# Setup Network Interface IDs
$nicids = create_and_setup_nic_ids $loc $rgname $vmconfig;
# Setup Image and Disks
$st = setup_image_and_disks $loc $rgname $stoname $vmconfig;
# Virtual Machine
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_1_crptestps5352 - Creating VM';
$vmname = $rgname + 'vm';
$st = New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vmconfig -Tags (Get-ComputeTestTag $global:ps_test_tag_name);
# Get VM
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_1_crptestps5352 - Getting VM';
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
# Remove
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_1_crptestps5352 - Removing VM';
$st = Remove-AzureRmVM -Name $vmname -ResourceGroupName $rgname -Force;
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_1_crptestps5352 - End';
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,174 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
# Warning: This code was generated by a tool.
#
# Changes to this file may cause incorrect behavior and will be lost if the
# code is regenerated.
$global:ps_test_tag_name = 'crptestps6050'
function get_vm_config_object
{
param ([string] $rgname, [string] $vmsize)
$st = Write-Verbose "Creating VM Config Object - Start";
$vmname = $rgname + 'vm';
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
$st = Write-Verbose "Creating VM Config Object - End";
return $p;
}
function get_created_storage_account_name
{
param ([string] $loc, [string] $rgname)
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - Start";
$stoname = $rgname + 'sto';
$stotype = 'Standard_GRS';
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - '${stotype}' & '${stoname}'";
$st = New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$st = Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Tags (Get-ComputeTestTag $global:ps_test_tag_name);
$st = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - End";
return $stoname;
}
function create_and_setup_nic_ids
{
param ([string] $loc, [string] $rgname, $vmconfig)
$st = Write-Verbose "Creating and getting NICs for '${loc}' and '${rgname}' - Start";
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ($rgname + 'subnet') -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ($rgname + 'vnet') -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet -Tag (Get-ComputeTestTag $global:ps_test_tag_name);
$vnet = Get-AzureRmVirtualNetwork -Name ($rgname + 'vnet') -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$nic_ids = @($null) * 1;
$nic0 = New-AzureRmNetworkInterface -Force -Name ($rgname + 'nic0') -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -Tag (Get-ComputeTestTag $global:ps_test_tag_name);
$nic_ids[0] = $nic0.Id;
$vmconfig = Add-AzureRmVMNetworkInterface -VM $vmconfig -Id $nic0.Id;
$st = Write-Verbose "Creating and getting NICs for '${loc}' and '${rgname}' - End";
return $nic_ids;
}
function create_and_setup_vm_config_object
{
param ([string] $loc, [string] $rgname, [string] $vmsize)
$st = Write-Verbose "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - Start";
$vmconfig = get_vm_config_object $rgname $vmsize
$user = "Foo12";
$password = $rgname + "BaR#123";
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = $rgname + "cn";
$vmconfig = Set-AzureRmVMOperatingSystem -VM $vmconfig -Windows -ComputerName $computerName -Credential $cred;
$st = Write-Verbose "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - End";
return $vmconfig;
}
function setup_image_and_disks
{
param ([string] $loc, [string] $rgname, [string] $stoname, $vmconfig)
$st = Write-Verbose "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - Start";
$osDiskName = 'osDisk';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$osDiskCaching = 'ReadWrite';
$vmconfig = Set-AzureRmVMOSDisk -VM $vmconfig -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
# Image Reference
$imgRef = Get-DefaultCRPImage -loc $loc;
$vmconfig = ($imgRef | Set-AzureRmVMSourceImage -VM $vmconfig);
# Do not add any data disks
$vmconfig.StorageProfile.DataDisks = $null;
$st = Write-Verbose "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - End";
return $vmconfig;
}
function ps_vm_dynamic_test_func_2_crptestps4847
{
# Setup
$rgname = 'crptestps4847';
try
{
$loc = 'Southeast Asia';
$vmsize = 'Standard_A0';
$st = Write-Verbose "Running Test ps_vm_dynamic_test_func_2_crptestps4847 - Start ${rgname}, ${loc} & ${vmsize}";
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_2_crptestps4847 - Creating Resource Group';
$st = New-AzureRmResourceGroup -Location $loc -Name $rgname -Tag (Get-ComputeTestTag $global:ps_test_tag_name) -Force;
$vmconfig = create_and_setup_vm_config_object $loc $rgname $vmsize;
# Setup Storage Account
$stoname = get_created_storage_account_name $loc $rgname;
# Setup Network Interface IDs
$nicids = create_and_setup_nic_ids $loc $rgname $vmconfig;
# Setup Image and Disks
$st = setup_image_and_disks $loc $rgname $stoname $vmconfig;
# Virtual Machine
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_2_crptestps4847 - Creating VM';
$vmname = $rgname + 'vm';
$st = New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vmconfig -Tags (Get-ComputeTestTag $global:ps_test_tag_name);
# Get VM
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_2_crptestps4847 - Getting VM';
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
# Remove
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_2_crptestps4847 - Removing VM';
$st = Remove-AzureRmVM -Name $vmname -ResourceGroupName $rgname -Force;
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_2_crptestps4847 - End';
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,174 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
# Warning: This code was generated by a tool.
#
# Changes to this file may cause incorrect behavior and will be lost if the
# code is regenerated.
$global:ps_test_tag_name = 'crptestps6050'
function get_vm_config_object
{
param ([string] $rgname, [string] $vmsize)
$st = Write-Verbose "Creating VM Config Object - Start";
$vmname = $rgname + 'vm';
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
$st = Write-Verbose "Creating VM Config Object - End";
return $p;
}
function get_created_storage_account_name
{
param ([string] $loc, [string] $rgname)
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - Start";
$stoname = $rgname + 'sto';
$stotype = 'Standard_GRS';
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - '${stotype}' & '${stoname}'";
$st = New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$st = Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Tags (Get-ComputeTestTag $global:ps_test_tag_name);
$st = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
$st = Write-Verbose "Creating and getting storage account for '${loc}' and '${rgname}' - End";
return $stoname;
}
function create_and_setup_nic_ids
{
param ([string] $loc, [string] $rgname, $vmconfig)
$st = Write-Verbose "Creating and getting NICs for '${loc}' and '${rgname}' - Start";
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ($rgname + 'subnet') -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ($rgname + 'vnet') -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet -Tag (Get-ComputeTestTag $global:ps_test_tag_name);
$vnet = Get-AzureRmVirtualNetwork -Name ($rgname + 'vnet') -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$nic_ids = @($null) * 1;
$nic0 = New-AzureRmNetworkInterface -Force -Name ($rgname + 'nic0') -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -Tag (Get-ComputeTestTag $global:ps_test_tag_name);
$nic_ids[0] = $nic0.Id;
$vmconfig = Add-AzureRmVMNetworkInterface -VM $vmconfig -Id $nic0.Id;
$st = Write-Verbose "Creating and getting NICs for '${loc}' and '${rgname}' - End";
return $nic_ids;
}
function create_and_setup_vm_config_object
{
param ([string] $loc, [string] $rgname, [string] $vmsize)
$st = Write-Verbose "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - Start";
$vmconfig = get_vm_config_object $rgname $vmsize
$user = "Foo12";
$password = $rgname + "BaR#123";
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = $rgname + "cn";
$vmconfig = Set-AzureRmVMOperatingSystem -VM $vmconfig -Windows -ComputerName $computerName -Credential $cred;
$st = Write-Verbose "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - End";
return $vmconfig;
}
function setup_image_and_disks
{
param ([string] $loc, [string] $rgname, [string] $stoname, $vmconfig)
$st = Write-Verbose "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - Start";
$osDiskName = 'osDisk';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$osDiskCaching = 'ReadWrite';
$vmconfig = Set-AzureRmVMOSDisk -VM $vmconfig -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
# Image Reference
$imgRef = Get-DefaultCRPImage -loc $loc;
$vmconfig = ($imgRef | Set-AzureRmVMSourceImage -VM $vmconfig);
# Do not add any data disks
$vmconfig.StorageProfile.DataDisks = $null;
$st = Write-Verbose "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - End";
return $vmconfig;
}
function ps_vm_dynamic_test_func_3_crptestps5200
{
# Setup
$rgname = 'crptestps5200';
try
{
$loc = 'Central US';
$vmsize = 'Standard_A6';
$st = Write-Verbose "Running Test ps_vm_dynamic_test_func_3_crptestps5200 - Start ${rgname}, ${loc} & ${vmsize}";
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_3_crptestps5200 - Creating Resource Group';
$st = New-AzureRmResourceGroup -Location $loc -Name $rgname -Tag (Get-ComputeTestTag $global:ps_test_tag_name) -Force;
$vmconfig = create_and_setup_vm_config_object $loc $rgname $vmsize;
# Setup Storage Account
$stoname = get_created_storage_account_name $loc $rgname;
# Setup Network Interface IDs
$nicids = create_and_setup_nic_ids $loc $rgname $vmconfig;
# Setup Image and Disks
$st = setup_image_and_disks $loc $rgname $stoname $vmconfig;
# Virtual Machine
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_3_crptestps5200 - Creating VM';
$vmname = $rgname + 'vm';
$st = New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vmconfig -Tags (Get-ComputeTestTag $global:ps_test_tag_name);
# Get VM
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_3_crptestps5200 - Getting VM';
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
# Remove
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_3_crptestps5200 - Removing VM';
$st = Remove-AzureRmVM -Name $vmname -ResourceGroupName $rgname -Force;
$st = Write-Verbose 'Running Test ps_vm_dynamic_test_func_3_crptestps5200 - End';
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,41 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public partial class ImageTests
{
public ImageTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestImage()
{
ComputeTestController.NewInstance.RunPsTest(@"Test-Image $null");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestImageCapture()
{
ComputeTestController.NewInstance.RunPsTest(@"Test-ImageCapture $null");
}
}
}

Просмотреть файл

@ -0,0 +1,249 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Test Images
#>
function Test-Image
{
param ($loc)
# Setup
$rgname = Get-ComputeTestResourceName
try
{
# Common
if ($loc -eq $null)
{
$loc = Get-ComputeVMLocation;
}
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# Create a VM first
$vmsize = 'Standard_A4';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
# Adding the same Nic but not set it Primary
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId -Primary;
# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';
# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
# $p.StorageProfile.OSDisk = $null;
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
$imgRef = Get-DefaultCRPImage -loc $loc;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
# Create Image using the VM's OS disk and data disks.
$imageName = 'image' + $rgname;
$imageConfig = New-AzureRmImageConfig -Location $loc;
Set-AzureRmImageOsDisk -Image $imageConfig -OsType 'Windows' -OsState 'Generalized' -BlobUri $osDiskVhdUri;
$imageConfig = Add-AzureRmImageDataDisk -Image $imageConfig -Lun 1 -BlobUri $dataDiskVhdUri1;
$imageConfig = Add-AzureRmImageDataDisk -Image $imageConfig -Lun 2 -BlobUri $dataDiskVhdUri2;
$imageConfig = Add-AzureRmImageDataDisk -Image $imageConfig -Lun 3 -BlobUri $dataDiskVhdUri2;
Assert-AreEqual 3 $imageConfig.StorageProfile.DataDisks.Count;
$imageConfig = Remove-AzureRmImageDataDisk -Image $imageConfig -Lun 3;
Assert-AreEqual 2 $imageConfig.StorageProfile.DataDisks.Count;
$createdImage = New-AzureRmImage -Image $imageConfig -ImageName $imageName -ResourceGroupName $rgname;
# Verify Image properties
Assert-NotNull $createdImage.Id;
Assert-AreEqual $imageName $createdImage.Name;
Assert-AreEqual 2 $createdImage.StorageProfile.DataDisks.Count;
Assert-AreEqual "Succeeded" $createdImage.ProvisioningState;
Assert-AreEqual $osDiskVhdUri $createdImage.StorageProfile.OsDisk.BlobUri;
Assert-AreEqual $dataDiskVhdUri1 $createdImage.StorageProfile.DataDisks[0].BlobUri;
Assert-AreEqual $dataDiskVhdUri2 $createdImage.StorageProfile.DataDisks[1].BlobUri;
# List and Delete Image
$images = Get-AzureRmImage -ResourceGroupName $rgname;
Assert-AreEqual 1 $images.Count;
Remove-AzureRmImage -ResourceGroupName $rgname -ImageName $imageName -Force;
$images = Get-AzureRmImage -ResourceGroupName $rgname;
Assert-AreEqual 0 $images.Count;
# Remove All VMs
Get-AzureRmVM -ResourceGroupName $rgname | Remove-AzureRmVM -ResourceGroupName $rgname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
function Test-ImageCapture
{
param ($loc)
# Setup
$rgname = Get-ComputeTestResourceName
try
{
# Common
if ($loc -eq $null)
{
$loc = Get-ComputeVMLocation;
}
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# Create a VM first
$vmsize = 'Standard_A4';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
# Adding the same Nic but not set it Primary
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId -Primary;
# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';
# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
# $p.StorageProfile.OSDisk = $null;
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
$imgRef = Get-DefaultCRPImage -loc $loc;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
# Get VM
$vm = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
Stop-AzureRmVM -ResourceGroupName $rgname -Name $vmname -Force;
Set-AzureRmVM -ResourceGroupName $rgname -Name $vmname -Generalize;
# Create Image through capture of the VM
$imageName = 'image' + $rgname;
$imageConfig = New-AzureRmImageConfig -Location $loc -SourceVirtualMachineId $vm.Id;
$createdImage = New-AzureRmImage -Image $imageConfig -ImageName $imageName -ResourceGroupName $rgname;
Assert-NotNull $createdImage.Id;
Assert-AreEqual $imageName $createdImage.Name;
Assert-AreEqual 2 $createdImage.StorageProfile.DataDisks.Count;
Assert-AreEqual "Succeeded" $createdImage.ProvisioningState;
Assert-AreEqual $osDiskVhdUri $createdImage.StorageProfile.OsDisk.BlobUri;
Assert-AreEqual $dataDiskVhdUri1 $createdImage.StorageProfile.DataDisks[0].BlobUri;
Assert-AreEqual $dataDiskVhdUri2 $createdImage.StorageProfile.DataDisks[1].BlobUri;
# List and Delete Image
$images = Get-AzureRmImage -ResourceGroupName $rgname;
Assert-AreEqual 1 $images.Count;
Remove-AzureRmImage -ResourceGroupName $rgname -ImageName $imageName -Force;
$images = Get-AzureRmImage -ResourceGroupName $rgname;
Assert-AreEqual 0 $images.Count;
# Remove All VMs
Get-AzureRmVM -ResourceGroupName $rgname | Remove-AzureRmVM -ResourceGroupName $rgname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Просмотреть файл

@ -0,0 +1,34 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class ResourceSkuTests
{
public ResourceSkuTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetResourceSku()
{
ComputeTestController.NewInstance.RunPsTest("Test-GetResourceSku");
}
}
}

Просмотреть файл

@ -0,0 +1,26 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
Test List Resource Skus
#>
function Test-GetResourceSku
{
$skulist = Get-AzureRmComputeResourceSku | where {$_.Locations -eq "westus"};
Assert-True { $skulist.Count -gt 0; }
$output = $skulist | Out-String;
Assert-True { $output.Contains("availabilitySets"); }
Assert-True { $output.Contains("virtualMachines"); }
}

Просмотреть файл

@ -0,0 +1,64 @@
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System;
using System.Collections.Generic;
using System.IO;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class RunnerTests
{
public RunnerTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}
[Fact]
public void ExecuteRunnerTests()
{
var mode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
var csmAuth = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION");
if (mode == null || csmAuth == null || mode.ToLower() != "record")
{
return;
}
var testFile = File.ReadAllLines("ScenarioTests\\RunnerTests.csv");
foreach (var line in testFile)
{
var tokens = line.Split(';');
var className = tokens[0];
var type = Type.GetType(className);
var constructorInfo = type.GetConstructor(Type.EmptyTypes);
for (int i = 1; i < tokens.Length; i++)
{
var method = tokens[i];
var testClassInstance = constructorInfo.Invoke(new object[] { });
var testMethod = type.GetMethod(method);
Console.WriteLine("Invoking method : " + testMethod);
testMethod.Invoke(testClassInstance, new object[] { });
Console.WriteLine("Method " + testMethod + " has finished");
}
}
}
private void FixCSMAuthEnvVariable(IDictionary<string, string> envDictionary)
{
var str = string.Empty;
foreach (var entry in envDictionary)
{
if (entry.Key != "AADClientId" && entry.Key != "ApplicationSecret")
{
str += string.Format("{0}={1};", entry.Key, entry.Value);
}
}
Environment.SetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION", str);
}
}
}

Просмотреть файл

@ -0,0 +1 @@
Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VMDynamicTests;RunVMDynamicTests
1 Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VMDynamicTests RunVMDynamicTests

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,36 @@
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class SqlIaaSExtensionTests
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor _logger;
public SqlIaaSExtensionTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output);
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlIaaSExtension()
{
ComputeTestController.NewInstance.RunPsTest(_logger, "Test-SetAzureRmVMSqlServerExtension");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlIaaSAKVExtension()
{
ComputeTestController.NewInstance.RunPsTest(_logger, "Test-SetAzureRmVMSqlServerAKVExtension");
}
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlIaaSExtensionWith2016Image()
{
ComputeTestController.NewInstance.RunPsTest(_logger, "Test-SetAzureRmVMSqlServerExtensionWith2016Image");
}
}
}

Просмотреть файл

@ -0,0 +1,379 @@
<#
.SYNOPSIS
1) Installs the SqlIaaS extension by calling Set-AzureRmVMSqlServerExtension cmdlet on a VM.
2) Calls Get-AzureRmVMSqlServerExtension cmdlet to check the status of the extension installation.
3) Verifies settings are correct given input
4) Update extension values
5) Verify changes
6) Test with correct Name and Version
7) Test with correct Name and incorrect Version
8) Test with incorrect Name and crrect Version
9) Test with incorrect Name and incorrect Version
#>
function Test-SetAzureRmVMSqlServerAKVExtension
{
Set-StrictMode -Version latest; $ErrorActionPreference = 'Stop'
# Setup
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Common
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# VM Profile & Hardware
$vmsize = 'Standard_A2';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
# Storage Account
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
# OS & Image
$user = "localadmin";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$p = Set-AzureRmVMSourceImage -VM $p -PublisherName MicrosoftSQLServer -Offer SQL2014SP1-WS2012R2 -Skus Enterprise -Version "latest"
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
#Do actual changes and work here
$extensionName = "SqlIaaSExtension";
# 1) Installs the SqlIaaS extension by calling Set-AzureRmVMSqlServerExtension cmdlet on a VM.
$securepfxpwd = ConvertTo-SecureString String "Amu6y/RzJcc7JBzdAdRVv6mk=" AsPlainText Force;
$aps_akv = New-AzureRmVMSqlServerKeyVaultCredentialConfig -ResourceGroupName $rgname -Enable -CredentialName "CredentialTesting" -AzureKeyVaultUrl "https://Testkeyvault.vault.azure.net/" -ServicePrincipalName "0326921f-bf005595337c" -ServicePrincipalSecret $securepfxpwd;
Set-AzureRmVMSqlServerExtension -KeyVaultCredentialSettings $aps_akv -ResourceGroupName $rgname -VMName $vmname -Version "1.2" -Verbose;
# 2) Calls Get-AzureRmVMSqlServerExtension cmdlet to check the status of the extension installation.
$extension = Get-AzureRmVMSqlServerExtension -ResourceGroupName $rgname -VmName $vmName -Name $extensionName;
# 3) Verifies settings are correct given input
Assert-AreEqual $extension.KeyVaultCredentialSettings.Credentials.Count 1;
Assert-AreEqual $extension.KeyVaultCredentialSettings.Credentials[0].CredentialName "CredentialTesting"
# 4) Update extension values
$aps_akv = New-AzureRmVMSqlServerKeyVaultCredentialConfig -ResourceGroupName $rgname -Enable -CredentialName "CredentialTest" -AzureKeyVaultUrl "https://Testkeyvault.vault.azure.net/" -ServicePrincipalName "0326921f-82af-4ab3-9d46-bf005595337c" -ServicePrincipalSecret $securepfxpwd;
Set-AzureRmVMSqlServerExtension -KeyVaultCredentialSettings $aps_akv -ResourceGroupName $rgname -VMName $vmname -Version "1.2" -Verbose;
# 5) Verify changes
$extension = Get-AzureRmVMSqlServerExtension -ResourceGroupName $rgname -VmName $vmName -Name $extensionName;
Assert-AreEqual $extension.KeyVaultCredentialSettings.Credentials.Count 2;
Assert-AreEqual $extension.KeyVaultCredentialSettings.Credentials[1].CredentialName "CredentialTest"
# 6) Test with correct Name and Version
Set-AzureRmVMSqlServerExtension -KeyVaultCredentialSettings $aps_akv -ResourceGroupName $rgname -VMName $vmName -Name $extensionName -Version "1.2"
# 7) Test with correct Name and incorrect Version
Set-AzureRmVMSqlServerExtension -KeyVaultCredentialSettings $aps_akv -ResourceGroupName $rgname -VMName $vmName -Name $extensionName -Version "1.*"
}
finally
{
# Cleanup
if(Get-AzureRmResourceGroup -Name $rgname -Location $loc)
{
#Remove-AzureRmResourceGroup -Name $rgname -Force;
}
}
}
function Test-SetAzureRmVMSqlServerExtension
{
Set-StrictMode -Version latest; $ErrorActionPreference = 'Stop'
# Setup
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Common
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# VM Profile & Hardware
$vmsize = 'Standard_A2';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
# Storage Account
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
# OS & Image
$user = "localadmin";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$p = Set-AzureRmVMSourceImage -VM $p -PublisherName MicrosoftSQLServer -Offer SQL2014SP1-WS2012R2 -Skus Enterprise -Version "latest"
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
#Do actual changes and work here
$extensionName = "SqlIaaSExtension";
# 1) Installs the SqlIaaS extension by calling Set-AzureRmVMSqlServerExtension cmdlet on a VM, with auto patching and auto backup settings.
$aps = New-AzureRmVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "Thursday" -MaintenanceWindowStartingHour 20 -MaintenanceWindowDuration 120 -PatchCategory "Important"
$storageBlobUrl = "https://$stoname.blob.core.windows.net";
$storageKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname).Key1;
$storageKeyAsSecureString = ConvertTo-SecureString -String $storageKey -AsPlainText -Force;
$abs = New-AzureRmVMSqlServerAutoBackupConfig -Enable -RetentionPeriodInDays 5 -ResourceGroupName $rgname -StorageUri $storageBlobUrl -StorageKey $storageKeyAsSecureString
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmname -Version "1.2" -Verbose -Name $extensionName;
# 2) Calls Get-AzureRmVMSqlServerExtension cmdlet to check the status of the extension installation.
$extension = Get-AzureRmVMSqlServerExtension -ResourceGroupName $rgname -VmName $vmName -Name $extensionName;
# 3) Verifies settings are correct given input
Assert-AreEqual $extension.AutoPatchingSettings.DayOfWeek "Thursday"
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowStartingHour 20
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowDuration 120
Assert-AreEqual $extension.AutoPatchingSettings.PatchCategory "Important"
Assert-AreEqual $extension.AutoBackupSettings.RetentionPeriod 5
Assert-AreEqual $extension.AutoBackupSettings.Enable $true
# 4) Update extension values
$aps = New-AzureRmVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "Monday" -MaintenanceWindowStartingHour 20 -MaintenanceWindowDuration 120 -PatchCategory "Important"
$abs = New-AzureRmVMSqlServerAutoBackupConfig -Enable -RetentionPeriodInDays 10 -ResourceGroupName $rgname -StorageUri $storageBlobUrl -StorageKey $storageKeyAsSecureString
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmname -Version "1.2" -Verbose -Name $extensionName;
# 5) Verify changes
$extension = Get-AzureRmVMSqlServerExtension -ResourceGroupName $rgname -VmName $vmName -Name $extensionName;
Assert-AreEqual $extension.AutoPatchingSettings.DayOfWeek "Monday"
Assert-AreEqual $extension.AutoBackupSettings.RetentionPeriod 10
# 6) Test with correct Name and Version
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmName -Name $extensionName -Version "1.2"
# 7) Test with correct Name and incorrect Version
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmName -Name $extensionName -Version "1.*"
}
finally
{
# Cleanup
if(Get-AzureRmResourceGroup -Name $rgname -Location $loc)
{
#Remove-AzureRmResourceGroup -Name $rgname -Force;
}
}
}
# Test setting up VM with Sql Server 2016 image. (Includes testing for AutoBackup V2)
function Test-SetAzureRmVMSqlServerExtensionWith2016Image
{
Set-StrictMode -Version latest; $ErrorActionPreference = 'Stop'
# Setup
$rgname = Get-ComputeTestResourceName
$loc = Get-ComputeVMLocation
try
{
# Common
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# VM Profile & Hardware
$vmsize = 'Standard_A2';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
# Storage Account
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
# OS & Image
$user = "localadmin";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$p = Set-AzureRmVMSourceImage -VM $p -PublisherName MicrosoftSQLServer -Offer SQL2016-WS2012R2 -Skus Enterprise -Version "latest"
# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
#Do actual changes and work here
$extensionName = "Microsoft.SqlServer.Management.SqlIaaSAgent";
# 1) Installs the SqlIaaS extension by calling Set-AzureRmVMSqlServerExtension cmdlet on a VM, with auto patching and auto backup settings.
$aps = New-AzureRmVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "Thursday" -MaintenanceWindowStartingHour 20 -MaintenanceWindowDuration 120 -PatchCategory "Important"
$storageBlobUrl = "https://$stoname.blob.core.windows.net";
$storageKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname).Key1;
$storageKeyAsSecureString = ConvertTo-SecureString -String $storageKey -AsPlainText -Force;
$abs = New-AzureRmVMSqlServerAutoBackupConfig -Enable -RetentionPeriodInDays 5 -ResourceGroupName $rgname -StorageUri $storageBlobUrl -StorageKey $storageKeyAsSecureString `
-BackupScheduleType Manual -BackupSystemDbs -FullBackupStartHour 10 -FullBackupWindowInHours 5 -FullBackupFrequency Daily -LogBackupFrequencyInMinutes 30
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmname -Version "1.2" -Verbose -Name $extensionName;
# 2) Calls Get-AzureRmVMSqlServerExtension cmdlet to check the status of the extension installation.
$extension = Get-AzureRmVMSqlServerExtension -ResourceGroupName $rgname -VmName $vmName -Name $extensionName;
# 3) Verifies settings are correct given input
Assert-AreEqual $extension.AutoPatchingSettings.DayOfWeek "Thursday"
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowStartingHour 20
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowDuration 120
Assert-AreEqual $extension.AutoPatchingSettings.PatchCategory "Important"
Assert-AreEqual $extension.AutoBackupSettings.RetentionPeriod 5
Assert-AreEqual $extension.AutoBackupSettings.Enable $true
Assert-AreEqual $extension.AutoBackupSettings.BackupScheduleType "Manual"
Assert-AreEqual $extension.AutoBackupSettings.FullBackupFrequency "Daily"
Assert-AreEqual $extension.AutoBackupSettings.BackupSystemDbs $true
Assert-AreEqual $extension.AutoBackupSettings.FullBackupStartTime 10
Assert-AreEqual $extension.AutoBackupSettings.FullBackupWindowHours 5
Assert-AreEqual $extension.AutoBackupSettings.LogBackupFrequency 30
# 4) Update extension values
$aps = New-AzureRmVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "Monday" -MaintenanceWindowStartingHour 20 -MaintenanceWindowDuration 120 -PatchCategory "Important"
$abs = New-AzureRmVMSqlServerAutoBackupConfig -Enable -RetentionPeriodInDays 10 -ResourceGroupName $rgname -StorageUri $storageBlobUrl `
-StorageKey $storageKeyAsSecureString -BackupScheduleType Automated
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmname -Version "1.2" -Verbose -Name $extensionName;
# 5) Verify changes
$extension = Get-AzureRmVMSqlServerExtension -ResourceGroupName $rgname -VmName $vmName -Name $extensionName;
Assert-AreEqual $extension.AutoPatchingSettings.DayOfWeek "Monday"
Assert-AreEqual $extension.AutoBackupSettings.RetentionPeriod 10
Assert-AreEqual $extension.AutoBackupSettings.Enable $true
Assert-AreEqual $extension.AutoBackupSettings.BackupScheduleType "Automated"
# 6) Test with correct Name and Version
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmName -Name $extensionName -Version "1.2"
# 7) Test with correct Name and incorrect Version
Set-AzureRmVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs -ResourceGroupName $rgname -VMName $vmName -Name $extensionName -Version "1.*"
}
finally
{
# Cleanup
if(Get-AzureRmResourceGroup -Name $rgname -Location $loc)
{
#Remove-AzureRmResourceGroup -Name $rgname -Force;
}
}
}
#helper methods for ARM
function Get-DefaultResourceGroupLocation
{
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
$namespace = "Microsoft.Resources"
$type = "resourceGroups"
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
if ($location -eq $null)
{
return "West US"
} else
{
return $location.Locations[0]
}
}
return "West US"
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше