-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select-AzureRMSubscription does not change the subscription from the default #6289
Comments
@dufc1923 would you mind upgrading to the latest version of |
Hi there, I've updated the module, its now showing version 5.1.0 and it does now seem to be working. Cheers,
ModuleType Version Name ExportedCommands Script 5.1.0 AzureRM.profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}
ModuleType Version Name ExportedCommands Script 4.3.0 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...} |
Issue has returned.. same issue as before.. PS C:> get-module azureRM.Profile -listavailable
ModuleType Version Name ExportedCommands Script 5.1.0 AzureRM.profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}
ModuleType Version Name ExportedCommands Script 4.3.0 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...} |
I have exactly the same issue after updating to azurerm version 6.1.1. Update: Issue: |
I'm experiencing the same issue with 6.1.0. |
@NateB2 @DdenBraver @dufc1923 Can you execute:
Also, try typing You can also always use Whenever there appears to be a problem with the saved context, And then open a new session, and log in again. If you are runnign interactively, you can run
To start fresh after any context-related issue. |
@markcowl - we're seeing the problem on VSTS build agents when running the Azure PowerShell task. Some of our subscriptions work great and others don't. It appears to be random. When I run |
@NateB2 So, if the issue is with VSTS, it seems unrelated to the above issue, and may be related to the change in context autosave settings. You should likely turn off context autosave for the user running the VSTS powershell scripts. (i.e. |
@markcowl Our issue seems to be related to a double login. It seems that when we connect with account B, and connect to a context that is also available in Account A that we cannot connect to its context. For some reason this always worked when using the older AzureRm module. And the latest combination where this still works fine is AzureRm 6.0.1 with AzureRm.Profile 5.0.1 Example code to reproduce:
To fix this issue, I added [Disconnect-AzureRmAccount] in between Login 1 and Login 2. |
@dufc1923 @DdenBraver @NateB2 Disconnecting the account is appropriate, when you have completed using those credentials, there may even be some underlying issue in switching between SPN and UPN for the same subscription (we'll take a look). In any case where you are running automation, it is good practice to use
At the beginning of your script. This disconnects your context from any dependency on the file system, which should speed things up dramatically in some cases, and prevent your scripts from interfering with each other, if running simultaneously. |
@dufc1923 @NateB2 @DdenBraver BTW - |
@dufc1923 Can you comment on whether using Disconnect-AzureRmAccount or Remove-AzureRmContext or Clear-AzureRmContext resolves your issue? |
@markcowl , The only one of those suggestuins that I've used is Disable-AzureRmContextAutosave and that does seem to have helped. The first workaround I used however was to use It seemed like specifying the subscription AND the tenant also helped to get me going again. Hope that's useful for others. |
@markcowl, those cmdlets did not work as a work-around for us. Set-AzureRMContext -SubscriptionId $subscriptionId -TenantId $tenantId also did not do the trick for us. |
@DdenBraver This is because you have context autosave enabled. Running Disable-AzureRmContextAutosave -Scope Process at the start of every automated script will ensure the script is isolated from previously saved contexts. The context is saved in user accound AppData by default. If you have multiple scripts that do login runnign simultaneously in this account, then you may consider turning off context autosave globally: |
Closing as the workaround worked for the original issue. Tracking the fix for the root cause here: #6489 @DdenBraver Since your issue appears to be different than this, if the above advice does not fix it, please file an issue with your particular issue details. |
@markcowl - the workaround worked for us as well - thanks! |
@markcowl Thank you. |
@Neblua Do you still have this issue when using the latest version? |
@DdenBraver after removing all azurerm modules and installing using the 6.3 MSI it appears to always work now when selecting subscription and when run as a scheduled task. |
Description
i set $subscriptionid to a specific subscription that exists..
but when I exectute Select-AzureRmSubscription -SubscriptionId $subscriptionid it doesnt set me to be using that subscription and I am left in my default subscription..
I've been using the command succesfully for months..
and even yesterday I used it about 3 or 4 times and it worked, then all of a sudden it stopped working..
Script/Steps for Reproduction
Module Version
ModuleType Version Name ExportedCommands
Script 5.0.1 AzureRM.profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}
Script 0.6.5 AzureRM.ServiceBus {New-AzureRmServiceBusNamespace, Get-AzureRmServiceBusNamespace, Set-AzureRmServiceBusNamespace, Remove-AzureRmServiceBusNamespace...}
ModuleType Version Name ExportedCommands
Script 0.6.3 AzureRM.AnalysisServices {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesServer, Get-AzureRmAnalysisServicesServer, Remove-AzureRmAnalysisServicesServer...}
Script 5.1.0 AzureRM.ApiManagement {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-AzureRmApiManagementHostnameConfiguration, New-AzureRmApiManagementRegion...}
Script 0.1.1 AzureRM.ApplicationInsights {Get-AzureRmApplicationInsights, New-AzureRmApplicationInsights, Remove-AzureRmApplicationInsights, Set-AzureRmApplicationInsightsPricingPlan...}
Script 4.2.1 AzureRM.Automation {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutomationJobOutputRecord, Import-AzureRmAutomationDscNodeConfiguration, Export-AzureRmAutomationDscConfiguration...}
Script 4.0.2 AzureRM.Backup {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerReregistration, Get-AzureRmBackupContainer, Register-AzureRmBackupContainer...}
Script 4.0.4 AzureRM.Batch {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-AzureRmBatchAccountKeys, New-AzureRmBatchAccount...}
Script 0.14.0 AzureRM.Billing {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod}
Script 4.1.0 AzureRM.Cdn {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-AzureRmCdnProfile, Remove-AzureRmCdnProfile...}
Script 0.9.1 AzureRM.CognitiveServices {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveServicesAccountKey, Get-AzureRmCognitiveServicesAccountSkus, New-AzureRmCognitiveServicesAccount...}
Script 4.3.2 AzureRM.Compute {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet...}
Script 0.3.0 AzureRM.Consumption Get-AzureRmConsumptionUsageDetail
Script 0.2.3 AzureRM.ContainerInstance {New-AzureRmContainerGroup, Get-AzureRmContainerGroup, Remove-AzureRmContainerGroup, Get-AzureRmContainerInstanceLog}
Script 1.0.2 AzureRM.ContainerRegistry {New-AzureRmContainerRegistry, Get-AzureRmContainerRegistry, Update-AzureRmContainerRegistry, Remove-AzureRmContainerRegistry...}
Script 4.1.0 AzureRM.DataFactories {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-AzureRmDataFactorySlice, Save-AzureRmDataFactoryLog...}
Script 0.5.0 AzureRM.DataFactoryV2 {Set-AzureRmDataFactoryV2, Update-AzureRmDataFactoryV2, Get-AzureRmDataFactoryV2, Remove-AzureRmDataFactoryV2...}
Script 4.2.1 AzureRM.DataLakeAnalytics {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLakeAnalyticsCatalogCredential, Remove-AzureRmDataLakeAnalyticsCatalogCredential, Remove-AzureRmDataLakeAnalyticsCatalogSecret...}
Script 5.1.1 AzureRM.DataLakeStore {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreFirewallRule, Set-AzureRmDataLakeStoreTrustedIdProvider...}
Script 0.1.0 AzureRM.DataMigration {New-AzureRmDataMigrationDatabaseInfo, New-AzureRmDataMigrationConnectionInfo, New-AzureRmDataMigrationProject, Remove-AzureRmDataMigrationProject...}
Script 4.0.2 AzureRM.DevTestLabs {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShutdownPolicy, Get-AzureRmDtlAutoStartPolicy, Get-AzureRmDtlVMsPerLabPolicy...}
Script 4.0.1 AzureRM.Dns {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRecordSet...}
Script 0.3.1 AzureRM.EventGrid {New-AzureRmEventGridTopic, Get-AzureRmEventGridTopic, Set-AzureRmEventGridTopic, New-AzureRmEventGridTopicKey...}
Script 0.6.1 AzureRM.EventHub {New-AzureRmEventHubNamespace, Get-AzureRmEventHubNamespace, Set-AzureRmEventHubNamespace, Remove-AzureRmEventHubNamespace...}
Script 4.0.2 AzureRM.HDInsight {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefinition, Wait-AzureRmHDInsightJob, New-AzureRmHDInsightStreamingMapReduceJobDefinition...}
Script 4.0.2 AzureRM.Insights {Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-AzureRmLogProfile, Get-AzureRmLogProfile...}
Script 3.1.0 AzureRM.IotHub {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGroup, Get-AzureRmIotHubConnectionString, Get-AzureRmIotHubJob...}
Script 4.1.1 AzureRM.KeyVault {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-AzureKeyVaultCertificateOperation, Get-AzureKeyVaultCertificateOperation...}
Script 4.0.1 AzureRM.LogicApp {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegrationAccountCallbackUrl, Get-AzureRmIntegrationAccountCertificate, Get-AzureRmIntegrationAccount...}
Script 0.17.0 AzureRM.MachineLearning {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentPlanUsageHistory, Remove-AzureRmMlCommitmentPlan...}
Script 0.4.0 AzureRM.MachineLearningCompute {Get-AzureRmMlOpCluster, Get-AzureRmMlOpClusterKey, Test-AzureRmMlOpClusterSystemServicesUpdateAvailability, Update-AzureRmMlOpClusterSystemService...}
Script 0.2.0 AzureRM.MarketplaceOrdering {Get-AzureRmMarketplaceTerms, Set-AzureRmMarketplaceTerms}
Script 0.9.0 AzureRM.Media {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServiceKey, Get-AzureRmMediaServiceKeys, Get-AzureRmMediaServiceNameAvailability...}
Script 5.2.0 AzureRM.Network {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmApplicationGatewayAuthenticationCertificate, Remove-AzureRmApplicationGatewayAuthenti...
Script 4.1.0 AzureRM.NotificationHubs {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAuthorizationRules, Get-AzureRmNotificationHubListKeys, Get-AzureRmNotificationHubPNSCredentials...}
Script 4.2.0 AzureRM.OperationalInsights {New-AzureRmOperationalInsightsAzureActivityLogDataSource, New-AzureRmOperationalInsightsCustomLogDataSource, Disable-AzureRmOperationalInsightsLinuxCustomLogCollection, Disable-AzureRmOperationalInsightsIISLo...
Script 4.1.2 AzureRM.PowerBIEmbedded {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollectionAccessKeys, Get-AzureRmPowerBIWorkspace...}
Script 4.3.0 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}
Script 4.0.2 AzureRM.RecoveryServices {Get-AzureRmRecoveryServicesBackupProperty, Get-AzureRmRecoveryServicesVault, Get-AzureRmRecoveryServicesVaultSettingsFile, New-AzureRmRecoveryServicesVault...}
Script 4.1.0 AzureRM.RecoveryServices.Backup {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecoveryServicesBackupManagementServer, Get-AzureRmRecoveryServicesBackupContainer, Unregister-AzureRmRecoveryServicesBackupContainer...}
Script 0.2.1 AzureRM.RecoveryServices.SiteRec... {Edit-AzureRmRecoveryServicesAsrRecoveryPlan, Get-AzureRmRecoveryServicesAsrAlertSetting, Get-AzureRmRecoveryServicesAsrEvent, Get-AzureRmRecoveryServicesAsrFabric...}
Script 4.1.0 AzureRM.RedisCache {Remove-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCacheScheduleEntry, Get-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCachePatchSchedule...}
Script 0.3.1 AzureRM.Relay {New-AzureRmRelayNamespace, Get-AzureRmRelayNamespace, Set-AzureRmRelayNamespace, Remove-AzureRmRelayNamespace...}
Script 0.1.1 AzureRM.Reservations {Get-AzureRmReservationOrder, Get-AzureRmReservation, Get-AzureRmReservationHistory, Update-AzureRmReservation...}
Script 5.4.0 AzureRM.Resources {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}
Script 0.16.1 AzureRM.Scheduler {Disable-AzureRmSchedulerJobCollection, Enable-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJob...}
Script 4.1.0 AzureRM.ServerManagement {Invoke-AzureRmServerManagementPowerShellCommand, Get-AzureRmServerManagementSession, New-AzureRmServerManagementSession, Remove-AzureRmServerManagementSession...}
Script 0.6.1 AzureRM.ServiceBus {New-AzureRmServiceBusNamespace, Get-AzureRmServiceBusNamespace, Set-AzureRmServiceBusNamespace, Remove-AzureRmServiceBusNamespace...}
Script 0.3.1 AzureRM.ServiceFabric {Add-AzureRmServiceFabricApplicationCertificate, Add-AzureRmServiceFabricClientCertificate, Add-AzureRmServiceFabricClusterCertificate, Add-AzureRmServiceFabricNode...}
Script 5.0.4 AzureRM.SiteRecovery {Get-AzureRmSiteRecoveryFabric, New-AzureRmSiteRecoveryFabric, Remove-AzureRmSiteRecoveryFabric, Stop-AzureRmSiteRecoveryJob...}
Script 4.2.0 AzureRM.Sql {Get-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseTransparentDataEncryptionActivity, Set-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseUpgradeHint...}
Script 4.2.1 AzureRM.Storage {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}
Script 4.0.2 AzureRM.StreamAnalytics {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnalyticsDefaultFunctionDefinition, New-AzureRmStreamAnalyticsFunction, Remove-AzureRmStreamAnalyticsFunction...}
Script 0.1.1 AzureRM.Subscription.Preview {Get-AzureRmSubscriptionDefinition, New-AzureRmSubscriptionDefinition}
Script 4.0.0 AzureRM.Tags {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script 4.0.1 AzureRM.TrafficManager {Disable-AzureRmTrafficManagerEndpoint, Enable-AzureRmTrafficManagerEndpoint, Set-AzureRmTrafficManagerEndpoint, Get-AzureRmTrafficManagerEndpoint...}
Script 4.0.1 AzureRM.UsageAggregates Get-UsageAggregates
Script 4.1.0 AzureRM.Websites {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServicePlan, Remove-AzureRmAppServicePlan...}
Environment Data
Debug Output
The text was updated successfully, but these errors were encountered: