Skip to content

Commit 8931221

Browse files
Merge branch 'dev' of https://github.com/Azure/azure-powershell into BugFixes
2 parents 674d0e0 + ec2a0c7 commit 8931221

File tree

181 files changed

+109553
-15073
lines changed

Some content is hidden

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

181 files changed

+109553
-15073
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
## Comments
2+
3+
---
4+
15
This checklist is used to make sure that common issues in a pull request are covered by the creator. You can find a more complete discussion of PowerShell cmdlet best practices [here](https://msdn.microsoft.com/en-us/library/dd878270(v=vs.85).aspx).
26

3-
Below in **Overall Changes**, check off the boxes that apply to your PR. Within each of the categories that you select, make sure that you can check off **all** of the boxes.
7+
Below in **Overall Changes**, check off the boxes that apply to your PR. For the categories that you did not check off, you can remove them from this body. Within each of the categories that you did select, make sure that you can check off **all** of the boxes.
8+
9+
For information on cleaning up the commits in your pull request, click [here](../documentation/cleaning-up-commits.md).
410

511
## Overall Changes
612
- [ ] [**MANDATORY** - General changes](#general)

AzurePowershell.Test.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
<XUnitTests Include=".\src\ResourceManager\AzureStackStorage\Commands.AzureStackStorage.Tests\bin\Debug\Microsoft.AzureStack.Commands.StorageAdmin.Test.dll"/>
101101
<XUnitTests Include=".\src\ResourceManager\DevTestLabs\Commands.DevTestLabs.Test\bin\Debug\Microsoft.Azure.Commands.DevTestLabs.Test.dll"/>
102102
<XUnitTests Include=".\src\ResourceManager\HDInsight\Commands.HDInsight.Test\bin\Debug\Commands.HDInsight.Test.dll"/>
103-
<XUnitTests Include=".\src\ResourceManager\Insights\Commands.Insights.Test\bin\Debug\Microsoft.Azure.Commands.Insights.Test.dll"/>
104-
<XUnitTests Include=".\src\ResourceManager\RecoveryServices\Commands.RecoveryServices.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServicesArm.Test.dll"/> -->
103+
<XUnitTests Include=".\src\ResourceManager\Insights\Commands.Insights.Test\bin\Debug\Microsoft.Azure.Commands.Insights.Test.dll"/> -->
104+
<XUnitTests Include=".\src\ResourceManager\RecoveryServices\Commands.RecoveryServices.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServicesArm.Test.dll"/>
105105
<XUnitTests Include=".\src\ResourceManager\RecoveryServices.Backup\Commands.RecoveryServices.Backup.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.dll"/>
106106
<XUnitTests Include=".\src\ResourceManager\RedisCache\Commands.RedisCache.Test\bin\Debug\Microsoft.Azure.Commands.RedisCache.Test.dll"/>
107107
<!--<XUnitTests Include=".\src\ResourceManager\ServerManagement\Commands.ServerManagement.Test\bin\Debug\Microsoft.Azure.Commands.ServerManagement.Test.dll"/>

documentation/cleaning-up-commits.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Cleaning up commits
2+
3+
### Best practices for keeping commits clean
4+
5+
During development, to make sure that your commit history stays clean while the branch you're based off of is changing, follow some of these rules:
6+
7+
1. **Rebase instead of merging**
8+
- When you need to update your branch with the changes made to the base branch, [rebasing](#rebasing) will change the commit that your branch is based off of, allowing you to add the changes from the base branch and not gain an extra commit that you would with merging
9+
2. **Large number of changes**
10+
- If you create a pull request that contains a large number of changes (*e.g.,* re-recording tests) that won't be able to be displayed on GitHub, separate your changes into multiple pull requests that reference each other.
11+
12+
### Number of commits
13+
14+
It can be difficult to follow the changes in a pull request when the number of commits that come with it become too large:
15+
- If a bug fix is being addressed, a single commit should be submitted
16+
- If a new feature is being introduced, then the pull request can have multiple logical commits with each commit clearly describing what it does
17+
18+
### Rebasing
19+
20+
Sometimes a pull request can be based on a much earlier commit in the branch that you are trying to merge into it, causing a large amount of commits and file changes to litter the pull request. In this case, it would be better to **rebase** (move branches around by changing the commit that they are based on). After rebasing, you will want to close the pull request and open a new one, which will now have fewer commits.
21+
22+
For example, if you're working from the branch **feature** and are trying to rebase with **master**, you may run one of the following commands:
23+
> `git rebase master`
24+
> `git rebase master feature`
25+
26+
You can also rebase with the following command:
27+
> `git pull --rebase`
28+
29+
A normal `git pull` is equivalent to `git fetch` followed by `git merge FETCH_HEAD`, but when you run `git pull --rebase`, it runs `git rebase` instead of `git merge`.
30+
31+
For more information on rebasing, click [here](https://git-scm.com/docs/git-rebase).
32+
33+
### Squashing
34+
35+
When your pull request has a group of commits that can be condensed into one, logical commit, use **squashing**. This will clean up the number of commits your pull request has while also grouping together common commits.
36+
37+
For example, if you wanted to squash the last three commits into one, you may run the following command:
38+
> `git rebase -i HEAD~3`
39+
40+
This will bring up an editor showing your last three commits. Pick a commit to keep (as the message), and squash the other two into it.
41+
42+
For more information on squashing, click [here](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Squashing-Commits).
43+
44+
### Cherry-picking
45+
46+
If you want to merge specific commits from another branch into the current one you are working from, use **cherry-picking**.
47+
48+
For example, if you're working on the **master** branch and want to pull commit X (the commit-hash) from the **feature** branch, you may run the following commands:
49+
> `git checkout master`
50+
> `git cherry-pick X -n`
51+
52+
The `-n`, or `--no-commit`, is recommended for cherry-picking because it won't automatically create a commit for the cherry-picked change; this will allow you to view the changes first and make sure that you want to add all everything from the cherry-picked commit.
53+
54+
Now, if you want to cherry-pick a range of commits, say X through Y, from the **feature** branch, you may run the following commands:
55+
> `git checkout -b temp-branch X`
56+
> `git rebase --onto master Y^`
57+
58+
For more information on cherry-picking, click [here](https://git-scm.com/docs/git-cherry-pick).

src/Common/Commands.Common.Authentication/Factories/ClientFactory.cs

Lines changed: 86 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Models;
1717
using Microsoft.Azure.Commands.Common.Authentication.Properties;
1818
using System;
19+
using System.Collections.Concurrent;
1920
using System.Collections.Generic;
2021
using System.Collections.Specialized;
22+
using System.Linq;
2123
using System.Net;
2224
using System.Net.Http;
2325
using System.Net.Http.Headers;
26+
using System.Threading;
2427

2528
namespace Microsoft.Azure.Commands.Common.Authentication.Factories
2629
{
@@ -30,12 +33,16 @@ public class ClientFactory : IClientFactory
3033

3134
private Dictionary<Type, IClientAction> _actions;
3235
private OrderedDictionary _handlers;
36+
private ReaderWriterLockSlim _actionsLock;
37+
private ReaderWriterLockSlim _handlersLock;
3338

3439
public ClientFactory()
3540
{
3641
_actions = new Dictionary<Type, IClientAction>();
42+
_actionsLock = new ReaderWriterLockSlim();
3743
UserAgents = new HashSet<ProductInfoHeaderValue>();
3844
_handlers = new OrderedDictionary();
45+
_handlersLock = new ReaderWriterLockSlim();
3946
}
4047

4148
public virtual TClient CreateArmClient<TClient>(AzureContext context, AzureEnvironment.Endpoint endpoint) where TClient : Microsoft.Rest.ServiceClient<TClient>
@@ -108,8 +115,7 @@ public virtual TClient CreateClient<TClient>(AzureContext context, AzureEnvironm
108115
public virtual TClient CreateClient<TClient>(AzureSMProfile profile, AzureEnvironment.Endpoint endpoint) where TClient : ServiceClient<TClient>
109116
{
110117
TClient client = CreateClient<TClient>(profile.Context, endpoint);
111-
112-
foreach (IClientAction action in _actions.Values)
118+
foreach (IClientAction action in GetActions())
113119
{
114120
action.Apply<TClient>(client, profile, endpoint);
115121
}
@@ -154,7 +160,7 @@ public virtual TClient CreateClient<TClient>(AzureSMProfile profile, AzureSubscr
154160

155161
TClient client = CreateClient<TClient>(context, endpoint);
156162

157-
foreach (IClientAction action in _actions.Values)
163+
foreach (IClientAction action in GetActions())
158164
{
159165
action.Apply<TClient>(client, profile, endpoint);
160166
}
@@ -242,34 +248,82 @@ public static HttpClientHandler CreateHttpClientHandler(string endpoint, ICreden
242248

243249
public void AddAction(IClientAction action)
244250
{
245-
if (action != null)
251+
_actionsLock.EnterWriteLock();
252+
try
253+
{
254+
if (action != null)
255+
{
256+
action.ClientFactory = this;
257+
_actions[action.GetType()] = action;
258+
}
259+
}
260+
finally
246261
{
247-
action.ClientFactory = this;
248-
_actions[action.GetType()] = action;
262+
_actionsLock.ExitWriteLock();
249263
}
250264
}
251265

252266
public void RemoveAction(Type actionType)
253267
{
254-
if (_actions.ContainsKey(actionType))
268+
_actionsLock.EnterWriteLock();
269+
try
255270
{
256-
_actions.Remove(actionType);
271+
if (_actions.ContainsKey(actionType))
272+
{
273+
_actions.Remove(actionType);
274+
}
275+
}
276+
finally
277+
{
278+
_actionsLock.ExitWriteLock();
257279
}
258280
}
259281

282+
private IClientAction[] GetActions()
283+
{
284+
IClientAction[] result = null;
285+
_actionsLock.EnterReadLock();
286+
try
287+
{
288+
result = _actions.Values.ToArray();
289+
}
290+
finally
291+
{
292+
_actionsLock.ExitReadLock();
293+
}
294+
295+
return result;
296+
}
297+
260298
public void AddHandler<T>(T handler) where T : DelegatingHandler, ICloneable
261299
{
262-
if (handler != null)
300+
_handlersLock.EnterWriteLock();
301+
try
263302
{
264-
_handlers[handler.GetType()] = handler;
303+
if (handler != null)
304+
{
305+
_handlers[handler.GetType()] = handler;
306+
}
307+
}
308+
finally
309+
{
310+
_handlersLock.ExitWriteLock();
265311
}
266312
}
267313

268314
public void RemoveHandler(Type handlerType)
269315
{
270-
if (_handlers.Contains(handlerType))
316+
_handlersLock.EnterWriteLock();
317+
try
318+
{
319+
if (_handlers.Contains(handlerType))
320+
{
321+
_handlers.Remove(handlerType);
322+
}
323+
}
324+
finally
271325
{
272-
_handlers.Remove(handlerType);
326+
_handlersLock.ExitWriteLock();
273327
}
274328
}
275329

@@ -296,24 +350,32 @@ public void AddUserAgent(string productName)
296350

297351
public DelegatingHandler[] GetCustomHandlers()
298352
{
299-
List<DelegatingHandler> newHandlers = new List<DelegatingHandler>();
300-
var enumerator = _handlers.GetEnumerator();
301-
while (enumerator.MoveNext())
353+
_handlersLock.EnterReadLock();
354+
try
302355
{
303-
var handler = enumerator.Value;
304-
ICloneable cloneableHandler = handler as ICloneable;
305-
if (cloneableHandler != null)
356+
List<DelegatingHandler> newHandlers = new List<DelegatingHandler>();
357+
var enumerator = _handlers.GetEnumerator();
358+
while (enumerator.MoveNext())
306359
{
307-
var newHandler = cloneableHandler.Clone();
308-
DelegatingHandler convertedHandler = newHandler as DelegatingHandler;
309-
if (convertedHandler != null)
360+
var handler = enumerator.Value;
361+
ICloneable cloneableHandler = handler as ICloneable;
362+
if (cloneableHandler != null)
310363
{
311-
newHandlers.Add(convertedHandler);
364+
var newHandler = cloneableHandler.Clone();
365+
DelegatingHandler convertedHandler = newHandler as DelegatingHandler;
366+
if (convertedHandler != null)
367+
{
368+
newHandlers.Add(convertedHandler);
369+
}
312370
}
313371
}
314-
}
315372

316-
return newHandlers.ToArray();
373+
return newHandlers.ToArray();
374+
}
375+
finally
376+
{
377+
_handlersLock.ExitReadLock();
378+
}
317379
}
318380
}
319381
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/Commands.Batch.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<Private>True</Private>
112112
</Reference>
113113
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
114-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.4-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
114+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.6-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
115115
<Private>True</Private>
116116
</Reference>
117117
<Reference Include="Microsoft.WindowsAzure.Configuration">

src/ResourceManager/AzureBatch/Commands.Batch.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<package id="Microsoft.Rest.ClientRuntime" version="2.3.2" targetFramework="net45" />
2323
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.2" targetFramework="net45" />
2424
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.8-preview" targetFramework="net45" />
25-
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.3.4-preview" targetFramework="net45" />
25+
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.3.6-preview" targetFramework="net45" />
2626
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.0" targetFramework="net45" />
2727
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
2828
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />

src/ResourceManager/Cdn/Commands.Cdn.Test/Commands.Cdn.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<Private>True</Private>
8888
</Reference>
8989
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
90-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.4-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
90+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.6-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
9191
<Private>True</Private>
9292
</Reference>
9393
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">

src/ResourceManager/Cdn/Commands.Cdn.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1717
<package id="Microsoft.Rest.ClientRuntime" version="2.3.2" targetFramework="net45" />
1818
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.2" targetFramework="net45" />
19-
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.3.4-preview" targetFramework="net45" />
19+
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.3.6-preview" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.Management" version="4.0.1" targetFramework="net45" />
2121
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
2222
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />

src/ResourceManager/CognitiveServices/CognitiveServices.Test/Commands.Management.CognitiveServices.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<Private>True</Private>
8585
</Reference>
8686
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
87-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.4-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
87+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.6-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
8888
<Private>True</Private>
8989
</Reference>
9090
<Reference Include="Microsoft.Threading.Tasks">

src/ResourceManager/CognitiveServices/CognitiveServices.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<package id="Microsoft.Rest.ClientRuntime" version="2.3.2" targetFramework="net45" />
1919
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.2" targetFramework="net45" />
2020
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.8-preview" targetFramework="net45" />
21-
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.3.4-preview" targetFramework="net45" />
21+
<package id="Microsoft.Rest.ClientRuntime.Azure.TestFramework" version="1.3.6-preview" targetFramework="net45" />
2222
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
2323
<package id="xunit" version="2.1.0" targetFramework="net45" />
2424
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5151
</Reference>
5252
<Reference Include="Microsoft.Azure.Management.ResourceManager">
53-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.1.1-preview\lib\net45\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
53+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.2.0-preview\lib\net45\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
5454
</Reference>
5555
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5656
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package id="Hyak.Common" version="1.0.3" targetFramework="net45" />
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
6-
<package id="Microsoft.Azure.Management.ResourceManager" version="1.1.1-preview" targetFramework="net45" />
6+
<package id="Microsoft.Azure.Management.ResourceManager" version="1.2.0-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Test.Framework" version="1.0.6052.28118-prerelease" targetFramework="net45" />
88
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
99
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<Private>True</Private>
103103
</Reference>
104104
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
105-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.4-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
105+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.3.6-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
106106
<Private>True</Private>
107107
</Reference>
108108
<Reference Include="Microsoft.Threading.Tasks">

0 commit comments

Comments
 (0)