Skip to content

Commit 339e014

Browse files
committed
Merge pull request #226 from markcowl/fixdynamic
Fix dynamic parameters with stateless profile
2 parents 62e45ce + 81d8263 commit 339e014

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ protected static AzureProfile InitializeDefaultProfile()
9797
return new AzureProfile();
9898
}
9999

100+
/// <summary>
101+
/// Get the context for the current profile before BeginProcessing is called
102+
/// </summary>
103+
/// <returns>The context for the current profile</returns>
104+
protected AzureContext GetCurrentContext()
105+
{
106+
if (Profile != null)
107+
{
108+
return Profile.Context;
109+
}
110+
111+
return CurrentProfile.Context;
112+
}
113+
100114
protected static void InitializeTokenCaches()
101115
{
102116
DefaultMemoryTokenCache = new TokenCache();

src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourcesBaseCmdlet.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ public GalleryTemplatesClient GalleryTemplatesClient
5353
{
5454
if (galleryTemplatesClient == null)
5555
{
56-
if(Profile == null)
57-
{
58-
Profile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
59-
}
60-
61-
galleryTemplatesClient = new GalleryTemplatesClient(Profile.Context);
56+
// since this accessor can be called before BeginProcessing, use GetCurrentContext if no
57+
// profile is passed in
58+
galleryTemplatesClient = new GalleryTemplatesClient(GetCurrentContext());
6259
}
6360
return galleryTemplatesClient;
6461
}

0 commit comments

Comments
 (0)