diff --git a/src/HDInsight/HDInsight/JobCommands/InvokeHiveCommand.cs b/src/HDInsight/HDInsight/JobCommands/InvokeHiveCommand.cs index 35ae4ac34742..22dfa623c0fa 100644 --- a/src/HDInsight/HDInsight/JobCommands/InvokeHiveCommand.cs +++ b/src/HDInsight/HDInsight/JobCommands/InvokeHiveCommand.cs @@ -109,12 +109,6 @@ public override void ExecuteCmdlet() var resourceGroup = SessionState.PSVariable.Get(UseAzureHDInsightClusterCommand.CurrentResourceGroup).Value.ToString(); - _credential = new BasicAuthenticationCloudCredentials - { - Username = clusterCred.UserName, - Password = clusterCred.Password.ConvertToString() - }; - if (clusterConnection == null || clusterCred == null) { throw new NullReferenceException( @@ -122,6 +116,12 @@ public override void ExecuteCmdlet() "The cluster or resource group specified is null. Please use the Use-AzHDInsightCluster command to connect to a cluster.")); } + _credential = new BasicAuthenticationCloudCredentials + { + Username = clusterCred.UserName, + Password = clusterCred.Password.ConvertToString() + }; + //get hive job var hivejob = hiveJobDefinitionCommand.GetHiveJob();