Skip to content
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

issue ServiceFabric/.../AddAzureRmServiceFabricNodeType.cs GetProfiles() NullReferenceException #8681

Closed
jagilber opened this issue Mar 4, 2019 · 2 comments
Assignees
Labels
Service Attention This issue is responsible by Azure service team. Service Fabric

Comments

@jagilber
Copy link
Member

jagilber commented Mar 4, 2019

Description

az / azurerm
issue ServiceFabric/.../AddAzureRmServiceFabricNodeType.cs GetProfiles() NullReferenceException.
Issue is caused by having an existing vm scale set with no extensions deployed in the same resource group as the service fabric cluster being modified by the add-azServiceFabricNodeType add-azureRMServiceFabricNodeType commands.

tested fix below is to not assume any extensions exist:

var ext = vm.VirtualMachineProfile.ExtensionProfile.Extensions.FirstOrDefault(
e =>
string.Equals(
e.Type,
Constants.ServiceFabricWindowsNodeExtName,
StringComparison.OrdinalIgnoreCase));
// Try to get Linux ext
if (ext == null)
{
ext = vm.VirtualMachineProfile.ExtensionProfile.Extensions.FirstOrDefault(
e =>
e.Type.Equals(
Constants.ServiceFabricLinuxNodeExtName,
StringComparison.OrdinalIgnoreCase));
}
if (ext != null)
{
existingFabricExtension = ext;
osProfile = vm.VirtualMachineProfile.OsProfile;
existingStorageProfile = vm.VirtualMachineProfile.StorageProfile;
existingNetworkProfile = vm.VirtualMachineProfile.NetworkProfile;
}
ext = vm.VirtualMachineProfile.ExtensionProfile.Extensions.FirstOrDefault(
e =>

jagilber@21ef225

                    var ext = vm.VirtualMachineProfile.ExtensionProfile?.Extensions.FirstOrDefault(
                        e =>
                        string.Equals(
                            e.Type,
                            Constants.ServiceFabricWindowsNodeExtName,
                            StringComparison.OrdinalIgnoreCase));


                    // Try to get Linux ext
                    if (ext == null)
                    {
                        ext = vm.VirtualMachineProfile.ExtensionProfile?.Extensions.FirstOrDefault(
                            e =>
                            e.Type.Equals(
                                Constants.ServiceFabricLinuxNodeExtName,
                                StringComparison.OrdinalIgnoreCase));
                    }


                    if (ext != null)
                    {
                        existingFabricExtension = ext;
                        osProfile = vm.VirtualMachineProfile.OsProfile;
                        existingStorageProfile = vm.VirtualMachineProfile.StorageProfile;
                        existingNetworkProfile = vm.VirtualMachineProfile.NetworkProfile;
                    }


                    ext = vm.VirtualMachineProfile.ExtensionProfile?.Extensions.FirstOrDefault(
                        e =>

fix however may be to also not enumerate vm scale sets that are not part of existing cluster being modified.
asking pg as there are similar workitems where all scale sets are being enumerated in resource group

Steps to reproduce

create new service fabric cluster in new resource group using defaults in portal
create new virtual machine scale set in same resource group using defaults in portal
(the vmss will not have any extensions installed and is what produces this issue)
run powershell command to add a new service fabric node type using example below.

# assumes existing cluster and existing scaleset with no extensions created with steps above
$VerbosePreference = $DebugPreference = "continue"
$pwd = ConvertTo-SecureString -String 'Password$123456' -AsPlainText -Force
Add-AzServiceFabricNodeType -ResourceGroupName $resourceGroupName -Name $clusterName -Capacity 5 -VmUserName $adminUserName -NodeType $newNodeTypeName -VmPassword $pwd

EXPECTED RESULTS:
a new nodetype (vm scale set) should be created in existing resource group and joined to cluster

ACTUAL RESULTS:

Add-AzServiceFabricNodeType : Object reference not set to an instance of an object.
At line:1 char:1
+ Add-AzServiceFabricNodeType -ResourceGroupName sfjagilber1nt1 -Name s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Add-AzServiceFabricNodeType], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ServiceFabric.Commands.AddAzureRmServiceFabricNodeType

Module versions

Directory: C:\Program Files\PowerShell\Modules


ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     1.3.1      Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAuto...
Script     1.0.1      Az.Aks                              Core,Desk {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAk...
Script     1.0.2      Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnal...
Script     1.0.0      Az.ApiManagement                    Core,Desk {Add-AzApiManagementRegion, Get-AzApiManagementS...
Script     1.0.0      Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, New-AzApplicationIns...
Script     1.1.1      Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAut...
Script     1.0.0      Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAccount, Get-...
Script     1.0.0      Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-...
Script     1.0.1      Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-A...
Script     1.0.1      Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitive...
Script     1.4.0      Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet...
Script     1.0.0      Az.ContainerInstance                Core,Desk {New-AzContainerGroup, Get-AzContainerGroup, Rem...
Script     1.0.1      Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContainerRegistr...
Script     1.0.1      Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Ge...
Script     1.0.0      Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New-AzDataLa...
Script     1.1.0      Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-Az...
Script     1.0.0      Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShu...
Script     1.0.0      Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remo...
Script     1.1.0      Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridTopic, Set...
Script     1.0.1      Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespac...
Script     1.0.0      Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefi...
Script     1.0.2      Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGr...
Script     1.0.2      Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCer...
Script     1.2.0      Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegr...
Script     1.0.0      Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-AzMlCommitm...
Script     1.0.0      Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.0.0      Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKeys, Set-AzMediaServ...
Script     1.0.1      Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-Az...
Script     1.2.1      Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertifica...
Script     1.0.0      Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificationHubAut...
Script     1.1.0      Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSo...
Script     1.0.0      Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPol...
Script     1.0.0      Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, Get-AzPowe...
Script     1.0.1      Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRec...
Script     1.0.0      Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-AzRedisCa...
Script     1.0.0      Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNamespace, Set...
Script     1.1.3      Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignmen...
Script     1.0.0      Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServiceBusName...
Script     1.0.1      Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricApplicationCertificate, Add-...
Script     1.0.2      Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey,...
Script     1.3.0      Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get...
Script     1.0.2      Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, ...
Script     1.0.0      Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsFunction, Get-AzStreamAnal...
Script     1.0.1      Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndpoint, Rem...
Script     1.1.1      Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New...

Debug output

DEBUG: AzureQoSEvent: CommandName - Add-AzServiceFabricNodeType; IsSuccess - False; Duration - 00:00:00.7871233; Exception - System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Azure.Commands.ServiceFabric.Commands.AddAzureRmServiceFabricNodeType.GetProfiles(VirtualMachineScaleSetExtensionProfile& vmExtProfile, VirtualMachineScaleSetOSProfile& osProfile, VirtualMachineScaleSetStorageProfile& storageProfile, VirtualMachineScaleSetNetworkProfile& networkProfile)
   at Microsoft.Azure.Commands.ServiceFabric.Commands.AddAzureRmServiceFabricNodeType.CreateVmss()
   at Microsoft.Azure.Commands.ServiceFabric.Commands.AddAzureRmServiceFabricNodeType.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 2:57:06 PM - AddAzureRmServiceFabricNodeType end processing.
DEBUG: 2:57:06 PM - AddAzureRmServiceFabricNodeType end processing.

Environment data

PS G:\github\azure-powershell\artifacts\Debug\Az.ServiceFabric> $psversiontable

Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Error output


@cormacpayne cormacpayne added Service Fabric Service Attention This issue is responsible by Azure service team. labels Mar 5, 2019
@cormacpayne
Copy link
Member

@a-santamaria Hey Alfredo, would you mind taking a look at this issue, or reassigning the issue to someone else from the Service Fabric team?

@a-santamaria
Copy link
Member

Thanks for reporting. Yes, I'll follow up to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Service Attention This issue is responsible by Azure service team. Service Fabric
Projects
None yet
Development

No branches or pull requests

3 participants