Issue with context after running new-azsubscription
Hi,
Our build servers are Windows 2016 Server and are installed as per this script:
install-packageprovider -name NuGet -MinimumVersion 2.8.5.201 -force Install-Module -Name PowerShellGet -RequiredVersion 2.0.1 -Force Install-Module -Name Az -RequiredVersion 3.0.0 -Force Install-Module -Name AzureAD -Force Enable-AzureRmAlias -Scope LocalMachine Install-Module -Name Az.Subscription -RequiredVersion 0.6.1-preview -AllowPrerelease -force -allowclobber
When we create a new subscription with the command when logged in with a service principle: (worked with the Azurerm module) New-AzSubscription -Name deleteagain -OfferType MS-AZR-0017P ` -EnrollmentAccountObjectId (Get-AzEnrollmentAccount)[0].ObjectId
The subscription creates Name Id TenantId State
deleteagain 62f5bee3-66a4-4d6b-b0f3-xxxxxxxxxxxxx xxxxxxxxxxxxx Enabled
However now any identity related commands fail: PS C:\Users\localadmin> get-azsubscription get-azsubscription : The Resource Manager context was not properly initialized. Please load the module again. At line:1 char:1
- get-azsubscription
-
+ CategoryInfo : NotSpecified: (:) [Get-AzSubscription], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Azure.Commands.Profile.GetAzureRMSubscription Command
PS C:\Users\localadmin> login-azaccount login-azaccount : Object reference not set to an instance of an object. At line:1 char:1
- login-azaccount
-
+ CategoryInfo : CloseError: (:) [Connect-AzAccount], NullReferenceException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
My modules are: PS C:\Users\localadmin> get-installedmodule
Version Name Repository Description
3.0.0 Az PSGallery Microsoft Azure PowerShell - Cmdlets t... 1.6.4 Az.Accounts PSGallery Microsoft Azure PowerShell - Accounts ... 1.1.0 Az.Advisor PSGallery Microsoft Azure PowerShell - Azure Adv... 1.0.2 Az.Aks PSGallery Microsoft Azure PowerShell - Azure man... 1.1.1 Az.AnalysisServices PSGallery Microsoft Azure PowerShell - Analysis ... 1.3.2 Az.ApiManagement PSGallery Microsoft Azure PowerShell - Api Manag... 1.0.2 Az.ApplicationInsights PSGallery Microsoft Azure PowerShell - Applicati... 1.3.4 Az.Automation PSGallery Microsoft Azure PowerShell - Automatio... 2.0.1 Az.Batch PSGallery Microsoft Azure PowerShell - Batch ser... 1.0.1 Az.Billing PSGallery Microsoft Azure PowerShell - Billing s... 1.4.0 Az.Cdn PSGallery Microsoft Azure PowerShell - CDN servi... 1.2.1 Az.CognitiveServices PSGallery Microsoft Azure PowerShell - Cognitive... 3.0.0 Az.Compute PSGallery Microsoft Azure PowerShell - Compute s... 1.0.1 Az.ContainerInstance PSGallery Microsoft Azure PowerShell - Container... 1.1.0 Az.ContainerRegistry PSGallery Microsoft Azure PowerShell - Container... 1.4.1 Az.DataFactory PSGallery Microsoft Azure PowerShell - Data Fact... 1.0.1 Az.DataLakeAnalytics PSGallery Microsoft Azure PowerShell - Data Lake... 1.2.4 Az.DataLakeStore PSGallery Microsoft Azure PowerShell - Azure Dat... 1.0.1 Az.DeploymentManager PSGallery PowerShell .Net Core Microsoft Azure P... 1.0.0 Az.DevTestLabs PSGallery Microsoft Azure PowerShell - DevTest L... 1.1.1 Az.Dns PSGallery Microsoft Azure PowerShell - DNS servi... 1.2.2 Az.EventGrid PSGallery Microsoft Azure PowerShell - Event Gri... 1.4.0 Az.EventHub PSGallery Microsoft Azure PowerShell - Event Hub... 1.1.2 Az.FrontDoor PSGallery Microsoft Azure PowerShell - Front Doo... 3.0.0 Az.HDInsight PSGallery Microsoft Azure PowerShell - HDInsight... 1.0.0 Az.HealthcareApis PSGallery Microsoft Azure PowerShell - Healthcar... 2.0.0 Az.IotHub PSGallery Microsoft Azure PowerShell - IoT Hub s... 1.3.1 Az.KeyVault PSGallery Microsoft Azure PowerShell - Key Vault... 1.3.1 Az.LogicApp PSGallery Microsoft Azure PowerShell - Logic App... 1.1.1 Az.MachineLearning PSGallery Microsoft Azure PowerShell - Machine L... 1.0.1 Az.ManagedServices PSGallery Microsoft Azure PowerShell - ManagedSe... 1.0.1 Az.MarketplaceOrdering PSGallery Microsoft Azure PowerShell - Marketpla... 1.1.0 Az.Media PSGallery Microsoft Azure PowerShell - Media ser... 1.4.0 Az.Monitor PSGallery Microsoft Azure PowerShell - Monitor s... 2.0.0 Az.Network PSGallery Microsoft Azure PowerShell - Networkin... 1.1.0 Az.NotificationHubs PSGallery Microsoft Azure PowerShell - Notificat... 1.3.3 Az.OperationalInsights PSGallery Microsoft Azure PowerShell - Operation... 1.1.3 Az.PolicyInsights PSGallery Microsoft Azure PowerShell - Azure Pol... 1.1.0 Az.PowerBIEmbedded PSGallery Microsoft Azure PowerShell - Power BI ... 1.0.0 Az.PrivateDns PSGallery Microsoft Azure PowerShell - Private D... 0.7.0 Az.Profile PSGallery Microsoft Azure PowerShell - Profile c... 2.0.1 Az.RecoveryServices PSGallery Microsoft Azure PowerShell - Recovery ... 1.1.1 Az.RedisCache PSGallery Microsoft Azure PowerShell - Redis Cac... 1.0.2 Az.Relay PSGallery Microsoft Azure PowerShell - Relay ser... 1.7.1 Az.Resources PSGallery Microsoft Azure PowerShell - Azure Res... 1.4.0 Az.ServiceBus PSGallery Microsoft Azure PowerShell - Service B... 2.0.0 Az.ServiceFabric PSGallery Microsoft Azure PowerShell - Service F... 1.1.0 Az.SignalR PSGallery Microsoft Azure PowerShell - Azure Sig... 2.0.0 Az.Sql PSGallery Microsoft Azure PowerShell - SQL servi... 1.9.0 Az.Storage PSGallery Microsoft Azure PowerShell - Storage s... 1.2.1 Az.StorageSync PSGallery Microsoft Azure PowerShell - Storage S... 1.0.0 Az.StreamAnalytics PSGallery Microsoft Azure PowerShell - Stream An... 0.6.1-preview Az.Subscription PSGallery Microsoft Azure PowerShell - Subscript... 1.0.2 Az.TrafficManager PSGallery Microsoft Azure PowerShell - Traffic M... 1.5.0 Az.Websites PSGallery Microsoft Azure PowerShell - App Servi... 2.0.2.61 AzureAD PSGallery Azure Active Directory V2 General Avai... 1.4.5 PackageManagement PSGallery PackageManagement (a.k.a. OneGet) is a... 2.0.1 PowerShellGet PSGallery PowerShell module with commands for di...
This stopping Azure adoption as we can't create subscriptions!
We have the same issue with 0.7.1-preview too
get-azcontext returns no name PS C:\Users\localadmin> get-azcontext
Name Account SubscriptionName Environment TenantId
XXXXXX... XXXXXX AzureCloud XXXX...
Hi @stephenfrichardson ,
I tried these steps you provided but failed to reproduce the same error, looks like it was specific to your tenant or subscription, can you provide more detail?
Hi, we have an enterprise agreement account and the behaviour is the same across all engineering, test and production tenants.
We recently switched to using the az modules, there are no problems using the new-azurermsubscription command on the azurerm modules.
I can do a screen sharing demo if you need more information .
after discussion, Az.Subscription-0.7.1-preview works, close this issue for now.
Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.