Skip to content

Commit 0617f61

Browse files
2 parents 8a42f4c + b8fb0f6 commit 0617f61

File tree

94 files changed

+32210
-5152
lines changed

Some content is hidden

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

94 files changed

+32210
-5152
lines changed

.azure-pipelines/powershell-core.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ variables:
55
LinuxImage: ubuntu-18.04
66
MacOSName: macOS
77
MacOSImage: macOS-10.14
8-
TestFramework: netcoreapp2.2
8+
TestFramework: netcoreapp2.1
99
TestTarget: Test
1010
Configuration: Debug
1111
DebugLocalBuildTasks: true
@@ -22,8 +22,8 @@ jobs:
2222
linux:
2323
OSName: ${{ variables.LinuxName }}
2424
ImageName: ${{ variables.LinuxImage }}
25-
macOS:
26-
OSName: ${{ variables.MacOSName }}
25+
macOS:
26+
OSName: ${{ variables.MacOSName }}
2727
ImageName: ${{ variables.MacOSImage }}
2828
pool:
2929
vmImage: $(ImageName)
@@ -47,8 +47,8 @@ jobs:
4747
linux:
4848
OSName: ${{ variables.LinuxName }}
4949
ImageName: ${{ variables.LinuxImage }}
50-
macOS:
51-
OSName: ${{ variables.MacOSName }}
50+
macOS:
51+
OSName: ${{ variables.MacOSName }}
5252
ImageName: ${{ variables.MacOSImage }}
5353
pool:
5454
vmImage: $(ImageName)
@@ -72,8 +72,8 @@ jobs:
7272
linux:
7373
OSName: ${{ variables.LinuxName }}
7474
ImageName: ${{ variables.LinuxImage }}
75-
macOS:
76-
OSName: ${{ variables.MacOSName }}
75+
macOS:
76+
OSName: ${{ variables.MacOSName }}
7777
ImageName: ${{ variables.MacOSImage }}
7878
pool:
7979
vmImage: $(ImageName)

.azure-pipelines/windows-powershell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
variables:
22
WindowsName: windows
33
WindowsImage: VS2017-Win2016
4-
TestFramework: netcoreapp2.2
4+
TestFramework: netcoreapp2.1
55
TestTarget: Test
66
Configuration: Debug
77
DebugLocalBuildTasks: true

src/Accounts/Accounts/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
-->
2020
## Upcoming Release
2121

22+
* Fixed an issue that may cause authentication errors in multi-process scenarios such as running multiple Azure PowerShell cmdlets using `Start-Job` [#9448]
23+
2224
## Version 1.9.0
2325
* Supported discovering environment setting by default and adding environment via `Add-AzEnvironment`
2426
* Update preloaded assemblies [#12024], [#11976]

src/Accounts/Authentication.ResourceManager/ProtectedFileProvider.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ public abstract class ProtectedFileProvider : IFileProvider, IDisposable
3636
public const int MaxTries = 30;
3737
static readonly TimeSpan RetryInterval = TimeSpan.FromMilliseconds(500);
3838
protected Stream _stream;
39-
object _initializationLock = new object();
39+
40+
/// <summary>
41+
/// Use a Mutex to prevent cross-process file I/O
42+
/// </summary>
43+
/// <returns></returns>
44+
private static readonly Mutex _initializationLock = new Mutex(false, @"Local\AzurePowerShellProtectedFileProviderInit");
4045
public string FilePath { get; set; }
4146

4247
protected IDataStore DataStore { get; set; }
4348

4449
/// <summary>
45-
///
50+
///
4651
/// </summary>
4752
public Stream Stream
4853
{
@@ -87,7 +92,8 @@ public StreamWriter CreateWriter()
8792

8893
protected virtual void InitializeStream()
8994
{
90-
lock (_initializationLock)
95+
_initializationLock.WaitOne();
96+
try
9197
{
9298
if (_stream == null)
9399
{
@@ -96,10 +102,13 @@ protected virtual void InitializeStream()
96102
{
97103
throw new UnauthorizedAccessException(string.Format(Resources.FileLockFailure, FilePath));
98104
}
99-
100105
_stream = stream;
101106
}
102107
}
108+
finally
109+
{
110+
_initializationLock.ReleaseMutex();
111+
}
103112
}
104113

105114
protected abstract Stream AcquireLock(string filePath);

src/Accounts/Authentication/Authentication/ProtectedFileTokenCache.cs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Hyak.Common;
1516
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1617
using Microsoft.Azure.Commands.Common.Authentication.Properties;
1718
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1819
using System;
1920
using System.IO;
2021
using System.Security.Cryptography;
22+
using System.Threading;
2123

2224
#if NETSTANDARD
2325
namespace Microsoft.Azure.Commands.Common.Authentication.Core
@@ -41,7 +43,10 @@ public class ProtectedFileTokenCache : TokenCache, IAzureTokenCache
4143
#endif
4244
"TokenCache.dat");
4345

44-
private static readonly object fileLock = new object();
46+
/// <summary>
47+
/// A mutex to prevent IO to token cache file across threads / processes.
48+
/// </summary>
49+
private static readonly Mutex fileLock = new Mutex(false, @"Local\AzurePowerShellAdalTokenCacheFile");
4550

4651
private static readonly Lazy<ProtectedFileTokenCache> instance = new Lazy<ProtectedFileTokenCache>(() => new ProtectedFileTokenCache());
4752

@@ -123,12 +128,13 @@ void EnsureStateSaved()
123128

124129
private void ReadFileIntoCache(string cacheFileName = null)
125130
{
126-
if(cacheFileName == null)
131+
if (cacheFileName == null)
127132
{
128133
cacheFileName = ProtectedFileTokenCache.CacheFileName;
129134
}
130135

131-
lock (fileLock)
136+
fileLock.WaitOne();
137+
try
132138
{
133139
if (_store.FileExists(cacheFileName))
134140
{
@@ -150,11 +156,15 @@ private void ReadFileIntoCache(string cacheFileName = null)
150156
}
151157
}
152158
}
159+
finally
160+
{
161+
fileLock.ReleaseMutex();
162+
}
153163
}
154164

155165
private void WriteCacheIntoFile(string cacheFileName = null)
156166
{
157-
if(cacheFileName == null)
167+
if (cacheFileName == null)
158168
{
159169
cacheFileName = ProtectedFileTokenCache.CacheFileName;
160170
}
@@ -165,19 +175,25 @@ private void WriteCacheIntoFile(string cacheFileName = null)
165175
var dataToWrite = Serialize();
166176
#endif
167177

168-
lock(fileLock)
178+
fileLock.WaitOne();
179+
try
169180
{
170181
if (HasStateChanged)
171182
{
172183
_store.WriteFile(cacheFileName, dataToWrite);
173-
HasStateChanged = false;
184+
HasStateChanged = false;
174185
}
175186
}
187+
finally
188+
{
189+
fileLock.ReleaseMutex();
190+
}
176191
}
177192

178193
private void EnsureCacheFile(string cacheFileName = null)
179194
{
180-
lock (fileLock)
195+
fileLock.WaitOne();
196+
try
181197
{
182198
if (_store.FileExists(cacheFileName))
183199
{
@@ -207,6 +223,10 @@ private void EnsureCacheFile(string cacheFileName = null)
207223
#endif
208224
_store.WriteFile(cacheFileName, dataToWrite);
209225
}
226+
finally
227+
{
228+
fileLock.ReleaseMutex();
229+
}
210230
}
211231
}
212232
}

src/Accounts/Authentication/AzureSessionInitializer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#if NETSTANDARD
2727
using Microsoft.Azure.Commands.Common.Authentication.Core;
2828
#endif
29+
using Hyak.Common;
2930

3031
namespace Microsoft.Azure.Commands.Common.Authentication
3132
{
@@ -73,8 +74,10 @@ static IAzureTokenCache InitializeTokenCache(IDataStore store, string cacheDirec
7374
var cachePath = Path.Combine(cacheDirectory, cacheFile);
7475
result = new ProtectedFileTokenCache(cachePath, store);
7576
}
76-
catch
77+
catch (Exception ex)
7778
{
79+
TracingAdapter.Information("[AzureSessionInitializer]: Cannot initialize token cache in 'CurrentUser' mode. Falling back to 'Process' mode.");
80+
TracingAdapter.Information($"[AzureSessionInitializer]: Message: {ex.Message}; Stacktrace: {ex.StackTrace}");
7881
}
7982
}
8083

@@ -159,10 +162,12 @@ static ContextAutosaveSettings InitializeSessionSettings(IDataStore store, strin
159162
store.WriteFile(autoSavePath, JsonConvert.SerializeObject(result));
160163
}
161164
}
162-
catch
165+
catch (Exception ex)
163166
{
164167
// ignore exceptions in reading settings from disk
165168
result.Mode = ContextSaveMode.Process;
169+
TracingAdapter.Information("[AzureSessionInitializer]: Cannot read settings from disk. Falling back to 'Process' mode.");
170+
TracingAdapter.Information($"[AzureSessionInitializer]: Message: {ex.Message}; Stacktrace: {ex.StackTrace}");
166171
}
167172

168173
return result;

src/Accounts/Authentication/Utilities/CustomAssemblyResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static class CustomAssemblyResolver
1010
private static IDictionary<string, Version> NetFxPreloadAssemblies =
1111
new Dictionary<string, Version>(StringComparer.InvariantCultureIgnoreCase)
1212
{
13-
{"Azure.Core", new Version("1.2.1.0")},
13+
{"Azure.Core", new Version("1.2.2.0")},
1414
{"Microsoft.Bcl.AsyncInterfaces", new Version("1.0.0.0")},
1515
{"Microsoft.IdentityModel.Clients.ActiveDirectory", new Version("3.19.2.6005")},
1616
{"Microsoft.IdentityModel.Clients.ActiveDirectory.Platform", new Version("3.19.2.6005")},

src/ApplicationInsights/ApplicationInsights.Test/ApplicationInsights.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Management.ApplicationInsights" Version="0.3.0-preview" />
15-
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
15+
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.1.0" />
1616
</ItemGroup>
1717

1818
</Project>

src/Automation/Automation.Test/Automation.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PropertyGroup>
1010
<RootNamespace>$(LegacyAssemblyPrefix)$(PsModuleName)$(AzTestAssemblySuffix)</RootNamespace>
1111
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
12-
<TargetFrameworks>netcoreapp2.2;netcoreapp2.1</TargetFrameworks>
12+
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
1313
</PropertyGroup>
1414

1515
<ItemGroup>
@@ -27,4 +27,4 @@
2727
<None Update="ScenarioTests\Resources\*.*" CopyToOutputDirectory="PreserveNewest" />
2828
</ItemGroup>
2929

30-
</Project>
30+
</Project>

src/Az.Test.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<!-- Build -->
1313
<PropertyGroup>
14-
<TargetFrameworks>netcoreapp2.2;netstandard2.0</TargetFrameworks>
14+
<TargetFrameworks>netcoreapp2.1;netstandard2.0</TargetFrameworks>
1515
<AssemblyName>$(AzAssemblyPrefix)$(PsModuleName)$(AzTestAssemblySuffix)</AssemblyName>
1616
<RootNamespace>$(AzAssemblyPrefix)$(PsModuleName)$(AzTestAssemblySuffix)</RootNamespace>
1717
<IsPackable>false</IsPackable>
@@ -40,4 +40,4 @@
4040
<None Update="ScenarioTests\*.ps1" CopyToOutputDirectory="PreserveNewest" />
4141
</ItemGroup>
4242

43-
</Project>
43+
</Project>

src/Compute/Compute/help/Disable-AzVmssDiskEncryption.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ Disables disk encryption on a VM scale set.
2424
## EXAMPLES
2525

2626
### Example 1
27-
```
27+
```powershell
2828
PS C:\> Disable-AzVmssDiskEncryption -ResourceGroupName "Group001" -VMScaleSetName "VMSS001"
2929
```
3030

3131
Disables disk encryption on the VM scale set named VMSS001 that belongs to the resource group named Group001.
3232

33+
### Example 2
34+
35+
Disables disk encryption on a VM scale set. (autogenerated)
36+
37+
```powershell <!-- Aladdin Generated Example -->
38+
Disable-AzVmssDiskEncryption -ResourceGroupName 'Group001' -VMScaleSetName 'VMSS001' -VolumeType OS
39+
```
40+
3341
## PARAMETERS
3442

3543
### -AsJob

src/Compute/Compute/help/Get-AzVMADDomainExtension.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ The **Get-AzVMADDomainExtension** cmdlet gets information about the specified Az
2323

2424
## EXAMPLES
2525

26+
### Example 1
27+
28+
Gets information about an AD domain extension. (autogenerated)
29+
30+
```powershell <!-- Aladdin Generated Example -->
31+
Get-AzVMADDomainExtension -Name 'AgentPool01' -ResourceGroupName myresourcegroup -VMName 'VM01'
32+
```
33+
2634
## PARAMETERS
2735

2836
### -DefaultProfile

src/Compute/Compute/help/Get-AzVMDiagnosticsExtension.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ The **Get-AzVMDiagnosticsExtension** cmdlet gets the settings of the Azure Diagn
2424
## EXAMPLES
2525

2626
### Example 1: Get the diagnostics extension applied to a virtual machine
27-
```
27+
```powershell
2828
PS C:\> Get-AzVMDiagnosticsExtension -ResourceGroupName "ResourceGroup11" -VMName "ContosoVM22"
2929
```
3030

3131
This command gets the diagnostics extension applied to the virtual machine named ContosoVM22.
3232

33+
### Example 2
34+
35+
Gets the settings of the Diagnostics extension on a virtual machine. (autogenerated)
36+
37+
```powershell <!-- Aladdin Generated Example -->
38+
Get-AzVMDiagnosticsExtension -Name 'AgentPool01' -ResourceGroupName 'ResourceGroup11' -Status -VMName 'ContosoVM22'
39+
```
40+
3341
## PARAMETERS
3442

3543
### -DefaultProfile

src/Compute/Compute/help/Get-AzVMDscExtensionStatus.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ When a configuration is applied this cmdlet produces output consistent with the
2424

2525
## EXAMPLES
2626

27+
### Example 1
28+
29+
Gets the status of the DSC extension handler for a virtual machine. (autogenerated)
30+
31+
```powershell <!-- Aladdin Generated Example -->
32+
Get-AzVMDscExtensionStatus -Name 'AgentPool01' -ResourceGroupName myresourcegroup -VMName 'VM01'
33+
```
34+
2735
## PARAMETERS
2836

2937
### -DefaultProfile

src/Compute/Compute/help/New-AzProximityPlacementGroup.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This cmdlet will create Proximity Placement Group resource.
2424
## EXAMPLES
2525

2626
### Example 1
27-
```
27+
```powershell
2828
PS C:\> New-AzureRmProximityPlacementGroup -ResourceGroupName $resourceGroupName -Name $proximityPlacementGroupName -Location $location -Tag @{key1 = "val1"}
2929
3030
ResourceGroupName : rg0
@@ -38,6 +38,14 @@ Tags : {"key1":"val1"}
3838

3939
This command creates a proximity place group in the given location.
4040

41+
### Example 2
42+
43+
Create Proximity Placement Group resource. (autogenerated)
44+
45+
```powershell <!-- Aladdin Generated Example -->
46+
New-AzProximityPlacementGroup -Location westus -Name 'AgentPool01' -ProximityPlacementGroupType <String> -ResourceGroupName myresourcegroup
47+
```
48+
4149
## PARAMETERS
4250

4351
### -AsJob

0 commit comments

Comments
 (0)