Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->
## Upcoming Release
* Set correct UserAgent for client-side telemetry for Az 4.0 preview
* Display user friendly error message when context is null in Az 4.0

## Version 1.6.4
* Add a deprecation message for `Resolve-Error` alias.
Expand Down
6 changes: 6 additions & 0 deletions src/Accounts/Accounts/CommonModule/ContextAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using System.Linq;
using System.Management.Automation;
using Microsoft.Azure.Commands.Profile.Properties;

namespace Microsoft.Azure.Commands.Common
{
Expand Down Expand Up @@ -170,6 +171,11 @@ internal Func<HttpRequestMessage, CancellationToken, Action, SignalDelegate, Nex
/// <returns></returns>
internal async Task AuthorizeRequest(IAzureContext context, string resourceId, HttpRequestMessage request, CancellationToken outerToken)
{
if (context == null || context.Account == null || context.Environment == null)
{
throw new InvalidOperationException(Resources.InvalidAzureContext);
}

await Task.Run(() =>
{
resourceId = context?.Environment?.GetAudienceFromRequestUri(request.RequestUri) ?? resourceId;
Expand Down
9 changes: 9 additions & 0 deletions src/Accounts/Accounts/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Accounts/Accounts/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -465,4 +465,7 @@
<data name="SovereignProfileDescription" xml:space="preserve">
<value>A snapshot of the service API versiosn available in Azure Sovereign Clouds and the Azure Global Cloud.</value>
</data>
<data name="InvalidAzureContext" xml:space="preserve">
<value>The context is invalid. Please login using Connect-AzAccount.</value>
</data>
</root>