Skip to content

Commit 74df39c

Browse files
Merge branch 'sergey-whatif' of https://github.com/sergey-shandar/azure-powershell into sergey-whatif
2 parents ef13db6 + 67e5b30 commit 74df39c

File tree

758 files changed

+38258
-114866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

758 files changed

+38258
-114866
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dotnet: 2.1.2
55
dist: trusty
66

77
env:
8-
- NAME="azure-powershell-core" CONFIG="Release"
8+
- NAME="azure-powershell-core" CONFIG="Debug"
99

1010
services:
1111
- docker
@@ -21,13 +21,14 @@ before_install:
2121

2222
script:
2323
- dotnet msbuild build.proj /t:BuildNetcore /p:Configuration=$CONFIG
24+
- dotnet test src/Azure.PowerShell.Netcore.Test.sln --filter="AcceptanceType=CheckIn" --configuration $CONFIG
2425

2526
after_success:
2627
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
2728
docker build . -t $DOCKER_USER/$NAME:$TRAVIS_COMMIT --build-arg CONFIG=$CONFIG;
2829
docker tag $DOCKER_USER/$NAME:$TRAVIS_COMMIT $DOCKER_USER/$NAME:$TRAVIS_BRANCH;
2930

30-
docker login -u $DOCKER_USER -p $DOCKER_PASS;
31+
echo "$DOCKER_PASS" | docker login -u $DOCKER_USER --password-stdin;
3132

3233
docker push $DOCKER_USER/$NAME:$TRAVIS_COMMIT;
3334
docker push $DOCKER_USER/$NAME:$TRAVIS_BRANCH;

Azure.PowerShell.Netcore.sln

Lines changed: 1 addition & 204 deletions
Large diffs are not rendered by default.

AzurePowershell.Test.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<CommonTestDebug>.\src\ServiceManagement\Common\Commands.Common.Test\bin\Debug\Microsoft.WindowsAzure.Commands.Common.Test.dll</CommonTestDebug>
88
<BackupTestDebug>.\src\ResourceManager\AzureBackup\Commands.AzureBackup.Test\bin\Debug\Microsoft.Azure.Commands.AzureBackup.Test.dll</BackupTestDebug>
99
<RecoveryServicesBackupTestDebug>.\src\ResourceManager\AzureBackup\Commands.RecoveryServices.Backup.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.dll</RecoveryServicesBackupTestDebug>
10-
<SiteRecoveryTestDebug>.\src\ResourceManager\SiteRecovery\Commands.SiteRecovery.Test\bin\Debug\Microsoft.Azure.Commands.SiteRecovery.Test.dll</SiteRecoveryTestDebug>
1110
<SqlTestDebug>.\src\ResourceManager\Sql\Commands.Sql.Test\bin\Debug\Microsoft.Azure.Commands.Sql.Test.dll</SqlTestDebug>
1211
<ComputeDebug>.\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.dll</ComputeDebug>
1312
<ComputeTestDebug>.\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.Test.dll</ComputeTestDebug>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To install the module containing the legacy RDFE cmdlets, run the following comm
3838
Install-Module -Name Azure
3939
```
4040

41-
If you have an earlier version of the Azure PowerShell modules installed from the PowerShell Gallery and would like to update to the latest version, run the following commands in an elevated PowerShell session:
41+
If you have an earlier version of the Azure PowerShell modules installed from the PowerShell Gallery and would like to update to the latest version, run the following commands in an elevated PowerShell session. Update-Module installs the new version side-by-side with the old version. It does not remove the old version.
4242

4343
```powershell
4444
# Update to the latest version of AzureRM

TestMappings.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
"src/ResourceManager/IotHub/": [
9595
".\\src\\ResourceManager\\IotHub\\Commands.IotHub.Test\\bin\\Debug\\Microsoft.Azure.Commands.IotHub.Test.dll"
9696
],
97+
"src/ResourceManager/DeviceProvisioningServices/": [
98+
".\\src\\ResourceManager\\DeviceProvisioningServices\\Commands.DeviceProvisioningServices.Test\\bin\\Debug\\Microsoft.Azure.Commands.DeviceProvisioningServices.dll"
99+
],
97100
"src/ResourceManager/KeyVault/": [
98101
".\\src\\ResourceManager\\Compute\\Commands.Compute.Test\\bin\\Debug\\Microsoft.Azure.Commands.Compute.Test.dll",
99102
".\\src\\ResourceManager\\KeyVault\\Commands.KeyVault.Test\\bin\\Debug\\Microsoft.Azure.Commands.KeyVault.Test.dll",
@@ -141,8 +144,7 @@
141144
],
142145
"src/ResourceManager/RecoveryServices/": [
143146
".\\src\\ResourceManager\\RecoveryServices.Backup\\Commands.RecoveryServices.Backup.Test\\bin\\Debug\\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.dll",
144-
".\\src\\ResourceManager\\RecoveryServices\\Commands.RecoveryServices.Test\\bin\\Debug\\Microsoft.Azure.Commands.RecoveryServicesArm.Test.dll",
145-
".\\src\\ResourceManager\\SiteRecovery\\Commands.SiteRecovery.Test\\bin\\Debug\\Microsoft.Azure.Commands.SiteRecovery.Test.dll"
147+
".\\src\\ResourceManager\\RecoveryServices\\Commands.RecoveryServices.Test\\bin\\Debug\\Microsoft.Azure.Commands.RecoveryServicesArm.Test.dll"
146148
],
147149
"src/ResourceManager/RedisCache/": [
148150
".\\src\\ResourceManager\\RedisCache\\Commands.RedisCache.Test\\bin\\Debug\\Microsoft.Azure.Commands.RedisCache.Test.dll"
@@ -159,16 +161,12 @@
159161
"src/ResourceManager/Scheduler/": [
160162
".\\src\\ResourceManager\\Scheduler\\Commands.Scheduler.Test\\bin\\Debug\\Microsoft.Azure.Commands.Scheduler.Test.dll"
161163
],
162-
"src/ResourceManager/ServerManagement/": [],
163164
"src/ResourceManager/ServiceBus/": [
164165
".\\src\\ResourceManager\\ServiceBus\\Commands.ServiceBus.Test\\bin\\Debug\\Microsoft.Azure.Commands.ServiceBus.Test.dll"
165166
],
166167
"src/ResourceManager/ServiceFabric/": [
167168
".\\src\\ResourceManager\\ServiceFabric\\Commands.ServiceFabric.Test\\bin\\Debug\\Microsoft.Azure.Commands.ServiceFabric.Test.dll"
168169
],
169-
"src/ResourceManager/SiteRecovery/": [
170-
".\\src\\ResourceManager\\SiteRecovery\\Commands.SiteRecovery.Test\\bin\\Debug\\Microsoft.Azure.Commands.SiteRecovery.Test.dll"
171-
],
172170
"src/ResourceManager/Sql/": [
173171
".\\src\\ResourceManager\\Sql\\Commands.Sql.Test\\bin\\Debug\\Microsoft.Azure.Commands.Sql.Test.dll"
174172
],

build.proj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<NetCore Condition=" $(NetCore) == '' " >false</NetCore>
5454
<SkipHelp Condition =" '$(SkipHelp)' == '' ">false</SkipHelp>
5555
<BuildTasksPath>$(LibraryToolsFolder)\BuildPackagesTask\Microsoft.Azure.Build.Tasks\bin\$(Configuration)</BuildTasksPath>
56-
<Stack Condition = "'$(Scope)' == '' or '$(Scope)' == 'all' or '$(Scope)' == 'Stack' ">true</Stack>
56+
<Stack Condition = "(('$(Scope)' == '' or '$(Scope)' == 'all') and '$(NetCore)' == 'false') or '$(Scope)' == 'Stack' ">true</Stack>
5757
<Latest Condition = "'$(Scope)' == '' or '$(Scope)' != 'Stack'">true</Latest>
5858
</PropertyGroup>
5959
<ItemGroup>
@@ -71,7 +71,7 @@
7171

7272
<StaticAnalysis Include=".\tools\StaticAnalysis\StaticAnalysis.sln" />
7373
<LocalBuildTasks Include="$(LibraryToolsFolder)\BuildPackagesTask\Microsoft.Azure.Build.Tasks.sln" />
74-
<LocalBuildTasks Include="$(LibraryToolsFolder)\RepoTasks\RepoTasks.sln" />
74+
<LocalBuildTasks Include="$(LibraryToolsFolder)\RepoTasks\RepoTasks.sln" Condition="'$(NetCore)' == 'false'"/>
7575
</ItemGroup>
7676

7777
<!-- Tasks -->
@@ -417,7 +417,7 @@
417417
Condition="!$(DelaySign) and '@(ScriptsToSign)' != ''"/>
418418

419419
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\CheckSignature.ps1 -CustomPath $(LibrarySourceFolder)\Package\$(Configuration) &quot;"
420-
ContinueOnError="ErrorAndContinue" />
420+
ContinueOnError="ErrorAndContinue" Condition="'$(NetCore)' == 'false'"/>
421421

422422
<!-- Copying signed shortcut back -->
423423
<Copy SourceFiles="$(LibrarySourceFolder)\Package\$(Configuration)\AzureRM.Netcore.psd1"

documentation/azure-powershell-modules.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ Below is a table of modules containing ARM cmdlets found in the [`AzureRM`](http
6060
| Reservations | `AzureRM.Reservations` | [![Reservations](https://img.shields.io/powershellgallery/v/AzureRM.Reservations.svg?style=flat-square&label=AzureRM.Reservations)](https://www.powershellgallery.com/packages/AzureRM.Reservations/) |
6161
| Resources | `AzureRM.Resources` | [![Resources](https://img.shields.io/powershellgallery/v/AzureRM.Resources.svg?style=flat-square&label=AzureRM.Resources)](https://www.powershellgallery.com/packages/AzureRM.Resources/) |
6262
| Scheduler | `AzureRM.Scheduler` | [![Scheduler](https://img.shields.io/powershellgallery/v/AzureRM.Scheduler.svg?style=flat-square&label=AzureRM.Scheduler)](https://www.powershellgallery.com/packages/AzureRM.Scheduler/) |
63-
| Server Management | `AzureRM.ServerManagement` | [![Server Management](https://img.shields.io/powershellgallery/v/AzureRM.ServerManagement.svg?style=flat-square&label=AzureRM.ServerManagement)](https://www.powershellgallery.com/packages/AzureRM.ServerManagement/) |
6463
| Service Bus | `AzureRM.ServiceBus` | [![Service Bus](https://img.shields.io/powershellgallery/v/AzureRM.ServiceBus.svg?style=flat-square&label=AzureRM.ServiceBus)](https://www.powershellgallery.com/packages/AzureRM.ServiceBus/) |
6564
| Service Fabric | `AzureRM.ServiceFabric` | [![Service Fabric](https://img.shields.io/powershellgallery/v/AzureRM.ServiceFabric.svg?style=flat-square&label=AzureRM.ServiceFabric)](https://www.powershellgallery.com/packages/AzureRM.ServiceFabric/) |
66-
| Site Recovery | `AzureRM.SiteRecovery` | [![Site Recovery](https://img.shields.io/powershellgallery/v/AzureRM.SiteRecovery.svg?style=flat-square&label=AzureRM.SiteRecovery)](https://www.powershellgallery.com/packages/AzureRM.SiteRecovery/) |
6765
| Sql | `AzureRM.Sql` | [![Sql](https://img.shields.io/powershellgallery/v/AzureRM.Sql.svg?style=flat-square&label=AzureRM.Sql)](https://www.powershellgallery.com/packages/AzureRM.Sql/) |
6866
| Storage | `AzureRM.Storage` | [![Storage](https://img.shields.io/powershellgallery/v/AzureRM.Storage.svg?style=flat-square&label=AzureRM.Storage)](https://www.powershellgallery.com/packages/AzureRM.Storage/) |
6967
| Stream Analytics | `AzureRM.StreamAnalytics` | [![Stream Analytics](https://img.shields.io/powershellgallery/v/AzureRM.StreamAnalytics.svg?style=flat-square&label=AzureRM.StreamAnalytics)](https://www.powershellgallery.com/packages/AzureRM.StreamAnalytics/) |

documentation/development-docs/azure-powershell-developer-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The following prerequisites should be completed before contributing to the Azure
5454
- Install the latest version of [Git](https://git-scm.com/downloads)
5555
- Install the latest version of [WiX](http://wixtoolset.org/releases/)
5656
- After installation, ensure that the path to "WiX Toolset\bin" has been added to your `PATH` environment variable
57-
- Install the [`platyPS` module](https://github.com/Azure/azure-powershell/blob/preview/documentation/help-generation.md#installing-platyps)
57+
- Install the [`platyPS` module](https://github.com/Azure/azure-powershell/blob/preview/documentation/development-docs/help-generation.md#installing-platyps)
5858
- Set the PowerShell [execution policy](https://technet.microsoft.com/en-us/library/ee176961.aspx) to **Unrestricted** for the following versions of PowerShell:
5959
- `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`
6060
- `C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe`
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
If you need an Azure Virtual Machine with all the [prerequisites](https://github.com/Azure/azure-powershell/blob/preview/documentation/development-docs/azure-powershell-developer-guide.md#prerequisites) installed and ready to build and test Powershell Azure - follow the steps below.
2+
3+
# Copy the PowerShell Azure VHD blob to your subscription and create a VM from it.
4+
5+
1. Make sure that you have the version 4.5.0 or above of the AzureRM.Compute PowerShell module. Run the following command to install it. This version has the "easy VM create" cmdlet that we are going to use in the script below to create a VM.
6+
```PowerShell
7+
Install-Module AzureRM.Compute --MinimumVersion 4.5.0
8+
```
9+
2. Email [email protected] to obtain a VHD SAS URI, and assign that unique URI to the variable below.
10+
```PowerShell
11+
$VhdSasUri = <vhd-sas-uri-requested-from-us>
12+
```
13+
3. Create some variables. **_Before setting the ```$Location``` variable - make sure your subscription supports virtual machine creation in the location._**
14+
```PowerShell
15+
$SubscriptionId = <subscription-id>
16+
$ResourceGroupName = <resource-group-name>
17+
#Make sure your subscription supports virtual machine creation in the location.
18+
$Location = <location>
19+
20+
$Random_5_digits = Get-Random -SetSeed (Get-Date).Second | ForEach-Object {$_.ToString().Substring(5)}
21+
$StorageAccountName = "poshazureenv" + $Random_5_digits
22+
$StorageContainerName = "vhds"
23+
24+
$VhdFileName = "ps-azure-env.vhd"
25+
$ImageName = "ps-azure-env-image"
26+
$VmName = "ps-azure-env"
27+
$VMSize= "Standard_D4s_v3"
28+
29+
$VmLogin = <login>
30+
$VmPassword = <password>
31+
32+
$ErrorActionPreference = "Stop"
33+
$VmCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $VmLogin, $(ConvertTo-SecureString -String $VmPassword -AsPlainText -Force)
34+
```
35+
4. Sign in to your Azure account.
36+
```PowerShell
37+
Connect-AzureRmAccount
38+
```
39+
5. Execute the Powershell script. The script essentially does the following:
40+
1. Checks if a **resource group** with the name ```$ResourceGroupName``` exists if not - creates it for you.
41+
2. Checks if a **storage account** with the name ```$StorageAccountName``` exists if not - creates it for you.
42+
3. Checks if a **storage account container** with the name ```$StorageAccountName``` exists if not - creates it for you.
43+
4. Copies a **VHD** from the location ```$VhdSasUri``` to you storage account container.
44+
5. Creates an **image** form the VHD with the ```$ImageName``` name.
45+
5. Creates a **VM** from the image with the ```$VmName``` name.
46+
```PowerShell
47+
function SelectSubscription() {
48+
Write-Host "==> SelectSubscription"
49+
$null = Select-AzureRmSubscription -SubscriptionId $SubscriptionId
50+
}
51+
52+
function CreateResourceGroupIfNone() {
53+
Write-Host "==> CreateResourceGroupIfNone"
54+
$null = Get-AzureRmResourceGroup -Name $ResourceGroupName -ErrorVariable rgNotPresent -ErrorAction SilentlyContinue
55+
if ($rgNotPresent) {
56+
$null = New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location
57+
Write-Host "`tCreated resource group $ResourceGroupName" -ForegroundColor Yellow
58+
}
59+
}
60+
61+
function CreateStorageIfNone() {
62+
Write-Host "==> CreateStorageIfNone"
63+
64+
# Storage Account
65+
Write-Host "`tStorage Account"
66+
try {
67+
$sa = Get-AzureRmStorageAccount -StorageAccountName $StorageAccountName -ResourceGroupName $ResourceGroupName
68+
} catch {
69+
if ($_ -like "*was not found*") {
70+
$sa = New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName -Location $Location -SkuName Standard_LRS
71+
Write-Host "`tCreated storage account $StorageAccountName." -ForegroundColor Yellow
72+
} else {
73+
throw $_.Exception
74+
}
75+
}
76+
77+
$script:StorageAccountContext = $sa.Context
78+
79+
# Storage Container
80+
Write-Host "`tStorage Container"
81+
try {
82+
$sc = Get-AzureStorageContainer -Name $StorageContainerName -Context $StorageAccountContext
83+
} catch {
84+
if ($_ -like "*Can not find the container*") {
85+
$sc = New-AzureStorageContainer -Name $StorageContainerName -Context $StorageAccountContext
86+
Write-Host "`tCreated storage container $StorageContainerName." -ForegroundColor Yellow
87+
} else {
88+
throw $_.Exception
89+
}
90+
}
91+
}
92+
93+
function CopyVhdBlob() {
94+
Write-Host "==> Start-AzureStorageBlobCopy"
95+
$null = Start-AzureStorageBlobCopy -AbsoluteUri $VhdSasUri -DestContainer $StorageContainerName -DestContext $StorageAccountContext -DestBlob $VhdFileName
96+
$Time = [System.Diagnostics.Stopwatch]::StartNew()
97+
Write-Host "==> Polling Azure Storage Blob Copy State..."
98+
$null = Get-AzureStorageBlobCopyState -Blob $VhdFileName -Container $StorageContainerName -Context $StorageAccountContext -WaitForComplete
99+
$CurrentTime = $Time.Elapsed
100+
$Elapsed = $([string]::Format("{0:d2}:{1:d2}:{2:d2}", $CurrentTime.hours, $CurrentTime.minutes, $CurrentTime.seconds))
101+
Write-Host "`tVHD blob has been copied. Time: $Elapsed" -ForegroundColor Yellow
102+
}
103+
104+
function CreateImageFromVhd() {
105+
Write-Host "==> CreateImageFromVhd"
106+
$Blob = Get-AzureStorageBlob -Context $StorageAccountContext -Container $StorageContainerName -Blob $VhdFileName
107+
$BlobUri = $Blob.ICloudBlob.Uri.AbsoluteUri
108+
109+
$ImageConfig = New-AzureRmImageConfig -Location $Location
110+
$ImageConfig = Set-AzureRmImageOsDisk -Image $ImageConfig -OsType Windows -OsState Generalized -BlobUri $BlobUri
111+
$script:Image = New-AzureRmImage -ImageName $ImageName -ResourceGroupName $ResourceGroupName -Image $ImageConfig
112+
}
113+
114+
function CreateVmFromImage() {
115+
Write-Host "==> CreateVmFromImage"
116+
New-AzureRmVm -Name $VmName -Location $Location -ResourceGroupName $ResourceGroupName -ImageName $Image.Id -Credential $VmCredential -Size $VmSize
117+
}
118+
119+
SelectSubscription
120+
CreateResourceGroupIfNone
121+
CreateStorageIfNone
122+
CopyVhdBlob
123+
CreateImageFromVhd
124+
CreateVmFromImage
125+
126+
Write-Host "==> All done."
127+
```
128+
129+
# Github Settings and Repository Setup
130+
You will need to set up the GitHub configuration so that commits appear with your GitHub name.
131+
```
132+
git config --global user.email "<Your email on GitHub>"
133+
```
134+
```
135+
git config --global user.name "<Your name>"
136+
```
137+
Next, you will need to follow the steps [here](https://github.com/Azure/azure-powershell/wiki/Azure-Powershell-Developer-Guide#environment-setup) to set up your local fork of Azure/azure-powershell.
138+
139+
# Building and Running Tests
140+
This image has been set up to build and run tests immediately. To build the project, run msbuild build.proj in the Developer Command Prompt for VS2015. Once this has completed, you can open your module in Visual Studio and start development there. To record tests, follow the instructions [here](https://github.com/Azure/azure-powershell/wiki/Azure-Powershell-Developer-Guide#recordingrunning-tests).

0 commit comments

Comments
 (0)