Skip to content

Commit 82316e3

Browse files
author
Hovsep Mkrtchyan
committed
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
2 parents 9989647 + 2981a22 commit 82316e3

File tree

132 files changed

+17845
-15242
lines changed

Some content is hidden

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

132 files changed

+17845
-15242
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
This repository contains a set of PowerShell cmdlets for developers and administrators to develop, deploy and manage Microsoft Azure applications.
55

6-
* For documentation on how to build and deploy applications to Microsoft Azure please see the [Microsoft Azure Documentation Center](http://azure.microsoft.com/en-us/documentation/).
7-
* For comprehensive documentation on the developer cmdlets see [How to install and configure Azure PowerShell](http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
6+
* For documentation on how to build and deploy applications to Microsoft Azure please see the [Microsoft Azure Documentation Center](https://azure.microsoft.com/en-us/documentation/).
7+
* For comprehensive documentation on the developer cmdlets see [How to install and configure Azure PowerShell](https://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
88
* For comprehensive documentation on the full set of Microsoft Azure cmdlets see [Microsoft Azure Management Center](http://go.microsoft.com/fwlink/?linkID=254459&clcid=0x409).
99

1010
## Features
@@ -55,17 +55,17 @@ For detail descriptions and examples of the cmdlets, type
5555

5656
## Supported Environments
5757

58-
* [Microsoft Azure](http://www.azure.microsoft.com)
58+
* [Microsoft Azure](https://azure.microsoft.com)
5959
* [Azure Stack](https://azure.microsoft.com/en-us/overview/azure-stack/)
60-
* [Windows Azure Pack](http://www.microsoft.com/en-us/server-cloud/windows-azure-pack.aspx)
61-
* [Microsoft Azure China](http://www.windowsazure.cn/)
60+
* [Windows Azure Pack](https://www.microsoft.com/en-us/server-cloud/windows-azure-pack.aspx)
61+
* [Microsoft Azure China](https://www.azure.cn/)
6262
* [USGovernment](https://azure.microsoft.com/en-us/features/gov/)
6363

6464
## Installation
6565

6666
### Microsoft Web Platform Installer
6767

68-
1. Install [Microsoft Web Platform Installer](http://www.microsoft.com/web/downloads/platform.aspx).
68+
1. Install [Microsoft Web Platform Installer](https://www.microsoft.com/web/downloads/platform.aspx).
6969
2. Open Microsoft Web Platform Installer and search for __Microsoft Azure PowerShell__.
7070
3. Install.
7171

@@ -84,15 +84,15 @@ You can also find the standalone installers for all the versions at [Downloads](
8484

8585
### Supported PowerShell Versions
8686

87-
* [Windows Management Framework 3] (http://www.microsoft.com/en-us/download/details.aspx?id=34595)
87+
* [Windows Management Framework 3] (https://www.microsoft.com/en-us/download/details.aspx?id=34595)
8888
* [Windows Management Framework 4] (https://www.microsoft.com/en-us/download/details.aspx?id=40855)
8989
* [Windows Management Framework 5] (https://www.microsoft.com/en-us/download/details.aspx?id=50395)
9090

9191
## Get Started
9292

9393
In general, following are the steps to start using Microsoft Azure PowerShell
9494

95-
* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
95+
* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](https://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
9696
* Option 1: Login with your Microsoft account or Organizational account directly from PowerShell. Microsoft Azure Active Directory authentication is used in this case. No management certificate is needed.
9797
* Starting from 1.0.0, you can use ```Add-AzureRmAccount -Credential``` to avoid the browser pop up for Organizational account.
9898
* To use RDFE cmdlets, use ```Add-AzureAccount```
@@ -120,7 +120,7 @@ New-AzureRmResourceGroup -Name myresourceGroup -Location "West US"
120120
Add-AzureRmAccount -EnvironmentName AzureChinaCloud
121121
122122
# use the cmdlets to manage your services/applications
123-
New-AzureRmResourceGroup -Name myresourceGroup -Location "Chine East"
123+
New-AzureRmResourceGroup -Name myresourceGroup -Location "China East"
124124
```
125125

126126
### Windows Azure Pack
@@ -181,10 +181,10 @@ Be sure to check out the [Microsoft Azure Developer Forums on Stack Overflow](ht
181181

182182
## Contribute Code or Provide Feedback
183183

184-
If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://windowsazure.github.com/guidelines.html).
184+
If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](https://azure.github.io/guidelines/).
185185

186186
If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-powershell/issues) section of the project.
187187

188188
# Learn More
189189

190-
* [Microsoft Azure Script Center](http://www.azure.microsoft.com/en-us/documentation/scripts/)
190+
* [Microsoft Azure Script Center](https://azure.microsoft.com/en-us/documentation/scripts/)

build.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<Scope Condition=" $(Scope) == '' " >all</Scope>
4646
</PropertyGroup>
4747
<ItemGroup>
48-
<CmdletSolutionsToBuild Include=".\src\ResourceManager\**\*.sln;.\src\ServiceManagement\ServiceManagement.sln;.\src\Storage\Storage.sln"
48+
<CmdletSolutionsToBuild Include=".\src\Storage\Storage.sln;.\src\ResourceManager\**\*.sln;.\src\ServiceManagement\ServiceManagement.sln"
4949
Exclude=".\src\ResourceManager\Intune\*.sln"
5050
Condition=" '$(Scope)' == 'all' "/>
5151
<CmdletSolutionsToBuild Include=".\src\ResourceManager\$(Scope)\*.sln"

setup/azurecmdfiles.wxi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,9 @@
30293029
<Component Id="cmpF7ADD37722F45985B5323202F35958F2" Guid="*">
30303030
<File Id="fil0FA91D9C31AF07DCD03BFB842FE2B77E" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Compute\Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.dll" />
30313031
</Component>
3032+
<Component Id="cmp9D64A1111722F25BC100121E73BE039E" Guid="*">
3033+
<File Id="filD9BAD7BE2D8E9E1E7DDA9BAED346E4B7" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Compute\Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.dll-Help.xml" />
3034+
</Component>
30323035
<Component Id="cmpE52498FB0431A601DD9FDE6F082DF1D4" Guid="*">
30333036
<File Id="fil1C2DE4A7227BA117EC30E177CDE33EBA" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Compute\Microsoft.WindowsAzure.Commands.ServiceManagement.Preview.dll" />
30343037
</Component>
@@ -3092,6 +3095,9 @@
30923095
<Component Id="cmp7F9F978DBE7D6715FA75FFB3BE40806E" Guid="*">
30933096
<File Id="filD8D9BC2D74630E2A6A9438D81BEBFE40" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Compute\Newtonsoft.Json.dll" />
30943097
</Component>
3098+
<Component Id="cmp4AA539549D58FD2D5DD3C404556F3DBB" Guid="*">
3099+
<File Id="fil4D8DA0FB6E8B4E47BD5A37E758BFC156" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Compute\PIR.psd1" />
3100+
</Component>
30953101
<Component Id="cmp348131C92750A7166DCA75757E409378" Guid="*">
30963102
<File Id="fil4C89A8A3AA200315DD08D7FD6DA12286" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Compute\ServiceManagementStartup.ps1" />
30973103
</Component>
@@ -5836,6 +5842,7 @@
58365842
<ComponentRef Id="cmp70D1D6B3A151E5DA4EBA09BA3F9FAD5F" />
58375843
<ComponentRef Id="cmpAC5C284B13829839B2AD819221131DB0" />
58385844
<ComponentRef Id="cmpF7ADD37722F45985B5323202F35958F2" />
5845+
<ComponentRef Id="cmp9D64A1111722F25BC100121E73BE039E" />
58395846
<ComponentRef Id="cmpE52498FB0431A601DD9FDE6F082DF1D4" />
58405847
<ComponentRef Id="cmpFD1814D8F2D73854649A52268A2C2A83" />
58415848
<ComponentRef Id="cmp9DF26170AD3B0860AAFF291D39DD9FC5" />
@@ -5857,6 +5864,7 @@
58575864
<ComponentRef Id="cmpBFA5705441B7DF4264EFE1632A830DF1" />
58585865
<ComponentRef Id="cmpA7662EDC9DDCCFD0290DDB9350660A6B" />
58595866
<ComponentRef Id="cmp7F9F978DBE7D6715FA75FFB3BE40806E" />
5867+
<ComponentRef Id="cmp4AA539549D58FD2D5DD3C404556F3DBB" />
58605868
<ComponentRef Id="cmp348131C92750A7166DCA75757E409378" />
58615869
<ComponentRef Id="cmp289352966E5E4647DF24D7FFCEA4200F" />
58625870
<ComponentRef Id="cmpA497DCDAF4262858EF7BF8F3E4A03F30" />

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTestBase.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Net.Security;
2525
using System.Reflection;
2626
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
27+
using System.Collections.Generic;
2728

2829
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
2930
{
@@ -58,6 +59,14 @@ protected void SetupManagementClients()
5859

5960
protected void RunPowerShellTest(params string[] scripts)
6061
{
62+
Dictionary<string, string> d = new Dictionary<string, string>();
63+
d.Add("Microsoft.Resources", null);
64+
d.Add("Microsoft.Features", null);
65+
d.Add("Microsoft.Authorization", null);
66+
d.Add("Microsoft.Compute", null);
67+
var providersToIgnore = new Dictionary<string, string>();
68+
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
69+
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
6170
using (UndoContext context = UndoContext.Current)
6271
{
6372
context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));

src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</Reference>
5757
<Reference Include="Microsoft.Azure.Management.HDInsight.Job">
5858
<SpecificVersion>False</SpecificVersion>
59-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.1.1.0-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
59+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.2.0.0-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.Storage">
6262
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>

src/ResourceManager/HDInsight/Commands.HDInsight.Test/HDInsightTestBase.cs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System;
16+
using System.Collections.Generic;
1517
using System.Management.Automation;
1618
using Hyak.Common;
1719
using Microsoft.Azure.Commands.HDInsight.Models;
1820
using Microsoft.Azure.Management.HDInsight.Models;
19-
using Microsoft.WindowsAzure.Commands.Common;
2021
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
2122
using Moq;
2223

@@ -41,9 +42,51 @@ public virtual void SetupTestsForManagement()
4142

4243
public virtual void SetupTestsForData()
4344
{
45+
hdinsightManagementMock = new Mock<AzureHdInsightManagementClient>();
4446
var cred = new BasicAuthenticationCloudCredentials {Username = "username", Password = "Password1!"};
4547
hdinsightJobManagementMock = new Mock<AzureHdInsightJobManagementClient>(ClusterName, cred);
4648
commandRuntimeMock = new Mock<ICommandRuntime>();
4749
}
50+
51+
public virtual void SetupManagementClientForJobTests()
52+
{
53+
// Update HDInsight Management properties for Job.
54+
var cluster1 = new Cluster
55+
{
56+
Id = "/subscriptions/" + Guid.NewGuid() + "/resourceGroups/" + ResourceGroupName + "/providers/Microsoft.HDInsight/clusters/" + ClusterName,
57+
Name = ClusterName,
58+
Location = Location,
59+
Properties = new ClusterGetProperties
60+
{
61+
ClusterVersion = "3.2",
62+
ClusterState = "Running",
63+
ClusterDefinition = new ClusterDefinition
64+
{
65+
ClusterType = ClusterType
66+
},
67+
QuotaInfo = new QuotaInfo
68+
{
69+
CoresUsed = 24
70+
},
71+
OperatingSystemType = OSType.Windows,
72+
ConnectivityEndpoints = new List<ConnectivityEndpoint> { new ConnectivityEndpoint { Location = ClusterName, Name = "HTTPS" } }
73+
}
74+
};
75+
76+
var listresponse = new ClusterListResponse { Clusters = new[] { cluster1 } };
77+
hdinsightManagementMock.Setup(c => c.ListClusters())
78+
.Returns(listresponse)
79+
.Verifiable();
80+
81+
hdinsightManagementMock.Setup(c => c.GetCluster(It.IsAny<string>(), It.IsAny<string>()))
82+
.Returns(new List<Cluster> { cluster1 })
83+
.Verifiable();
84+
85+
var configurationResponse = new Dictionary<string, string>();
86+
87+
hdinsightManagementMock.Setup(c => c.GetClusterConfigurations(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
88+
.Returns(configurationResponse)
89+
.Verifiable();
90+
}
4891
}
4992
}

src/ResourceManager/HDInsight/Commands.HDInsight.Test/UnitTests/JobTests.cs

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
using System.Collections.Generic;
1616
using System.Management.Automation;
1717
using System.Net;
18+
using System.Linq;
1819
using Microsoft.Azure.Commands.HDInsight.Models;
1920
using Microsoft.Azure.Management.HDInsight.Job.Models;
2021
using Microsoft.WindowsAzure.Commands.Common;
2122
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2223
using Moq;
2324
using Xunit;
25+
using Microsoft.Azure.Management.HDInsight.Models;
2426

2527
namespace Microsoft.Azure.Commands.HDInsight.Test
2628
{
@@ -195,14 +197,93 @@ public void CreateStreamingJob()
195197
job.Reducer == reducer && job.Defines.Count == defines.Count)));
196198
}
197199

198-
[Fact(Skip = "Test requires setting env variable, TODO remove that constraint")]
200+
[Fact]
201+
[Trait(Category.AcceptanceType, Category.CheckIn)]
202+
public void GetJobWithIdProvided()
203+
{
204+
// Update HDInsight Management properties for Job.
205+
SetupManagementClientForJobTests();
206+
207+
var jobId = "jobid_1984120_001";
208+
var cmdlet = GetJobCommandDefinition();
209+
cmdlet.JobId = jobId;
210+
211+
// Setup Job Management mocks
212+
var jobResponse = new JobGetResponse
213+
{
214+
JobDetail = new JobDetailRootJsonObject { Id = jobId, Status = new Status(), Userargs = new Userargs() }
215+
};
216+
217+
hdinsightJobManagementMock.Setup(c => c.GetJob(It.IsAny<string>()))
218+
.Returns(jobResponse)
219+
.Verifiable();
220+
221+
cmdlet.ExecuteCmdlet();
222+
commandRuntimeMock.VerifyAll();
223+
commandRuntimeMock.Verify(
224+
f =>
225+
f.WriteObject(It.Is<AzureHDInsightJob>(job => job.JobId.Equals(jobId))));
226+
}
227+
228+
[Fact]
229+
[Trait(Category.AcceptanceType, Category.CheckIn)]
230+
public void ListJobs()
231+
{
232+
// Update HDInsight Management properties for Job.
233+
SetupManagementClientForJobTests();
234+
235+
var cmdlet = GetJobCommandDefinition();
236+
237+
// Setup Job Management mocks
238+
var jobListResponse = GetJobListResponse();
239+
240+
hdinsightJobManagementMock.Setup(c => c.ListJobs())
241+
.Returns(jobListResponse)
242+
.Verifiable();
243+
244+
cmdlet.ExecuteCmdlet();
245+
commandRuntimeMock.VerifyAll();
246+
commandRuntimeMock.Verify(
247+
f =>
248+
f.WriteObject(It.Is<IEnumerable<string>>(job => job.ElementAt(0).Equals(jobListResponse.ElementAt(0).Detail.Id) && job.ElementAt(1).Equals(jobListResponse.ElementAt(1).Detail.Id)), true));
249+
}
250+
251+
[Fact]
252+
[Trait(Category.AcceptanceType, Category.CheckIn)]
253+
public void ListJobsAfterJobId()
254+
{
255+
// Update HDInsight Management properties for Job.
256+
SetupManagementClientForJobTests();
257+
258+
var cmdlet = GetJobCommandDefinition();
259+
cmdlet.NumOfJobs = 2;
260+
261+
// Setup Job Management mocks
262+
var jobListResponse = GetJobListResponse();
263+
264+
hdinsightJobManagementMock.Setup(c => c.ListJobsAfterJobId(It.IsAny<string>(), It.IsAny<int>()))
265+
.Returns(jobListResponse)
266+
.Verifiable();
267+
268+
cmdlet.ExecuteCmdlet();
269+
commandRuntimeMock.VerifyAll();
270+
commandRuntimeMock.Verify(
271+
f =>
272+
f.WriteObject(It.Is<IEnumerable<AzureHDInsightJob>>(job => job.ElementAt(0).JobId.Equals(jobListResponse.ElementAt(0).Detail.Id) && job.ElementAt(1).JobId.Equals(jobListResponse.ElementAt(1).Detail.Id)), true));
273+
}
274+
275+
[Fact]
199276
[Trait(Category.AcceptanceType, Category.CheckIn)]
200277
public void StartJob()
201278
{
279+
// Update HDInsight Management properties for Job.
280+
SetupManagementClientForJobTests();
281+
202282
var cmdlet = new StartAzureHDInsightJobCommand
203283
{
204284
CommandRuntime = commandRuntimeMock.Object,
205285
HDInsightJobClient = hdinsightJobManagementMock.Object,
286+
HDInsightManagementClient = hdinsightManagementMock.Object,
206287
HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()),
207288
ClusterName = ClusterName
208289
};
@@ -246,7 +327,9 @@ public void StartJob()
246327
{
247328
Completed = "false",
248329
User = cmdlet.HttpCredential.UserName,
249-
Id = jobid
330+
Id = jobid,
331+
Status = new Status(),
332+
Userargs = new Userargs()
250333
}
251334
};
252335
hdinsightJobManagementMock.Setup(c => c.GetJob(jobsub.JobSubmissionJsonResponse.Id)).Returns(getresponse).Verifiable();
@@ -259,5 +342,42 @@ public void StartJob()
259342
It.Is<AzureHDInsightJob>(
260343
job => job.Cluster == ClusterName && job.JobId == jobid && job.Completed == "false")));
261344
}
345+
346+
public JobListResponse GetJobListResponse()
347+
{
348+
var jobListobject1 = new JobListJsonObject
349+
{
350+
Detail = new JobDetailRootJsonObject { Id = "jobid_1984120_001", Status = new Status(), Userargs = new Userargs() },
351+
Id = "jobid_1984120_001"
352+
};
353+
354+
var jobListobject2 = new JobListJsonObject
355+
{
356+
Detail = new JobDetailRootJsonObject { Id = "jobid_1984120_002", Status = new Status(), Userargs = new Userargs() },
357+
Id = "jobid_1984120_002"
358+
};
359+
360+
var jobListResponse = new JobListResponse
361+
{
362+
JobList = new List<JobListJsonObject> { jobListobject1, jobListobject2 },
363+
StatusCode = HttpStatusCode.OK
364+
};
365+
366+
return jobListResponse;
367+
}
368+
369+
public GetAzureHDInsightJobCommand GetJobCommandDefinition()
370+
{
371+
var cmdlet = new GetAzureHDInsightJobCommand
372+
{
373+
CommandRuntime = commandRuntimeMock.Object,
374+
HDInsightJobClient = hdinsightJobManagementMock.Object,
375+
HDInsightManagementClient = hdinsightManagementMock.Object,
376+
HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()),
377+
ClusterName = ClusterName
378+
};
379+
380+
return cmdlet;
381+
}
262382
}
263383
}

0 commit comments

Comments
 (0)