@@ -63,26 +63,23 @@ public override void ExecuteCmdlet()
63
63
if ( isDiscoveryNeed )
64
64
{
65
65
RefreshContainer ( ) ;
66
- }
67
-
68
- isDiscoveryNeed = IsDiscoveryNeeded ( vmName , rgName , out container ) ;
69
- if ( ( isDiscoveryNeed == false ) && ( container == null ) )
70
- {
71
- //Container is not discovered. Throw exception
72
- throw new NotImplementedException ( ) ;
73
- }
74
- else
75
- {
76
- //Container is discovered. Register the container
77
- List < string > containerNameList = new List < string > ( ) ;
78
- containerNameList . Add ( container . Name ) ;
79
- RegisterContainerRequest registrationRequest = new RegisterContainerRequest ( containerNameList , AzureBackupContainerType . IaasVMContainer . ToString ( ) ) ;
80
- operationResponse = AzureBackupClient . Container . RegisterAsync ( registrationRequest , GetCustomRequestHeaders ( ) , CmdletCancellationToken ) . Result ;
81
-
82
- //TODO fix the OperationResponse to JobID conversion
83
- jobId = operationResponse . OperationId ;
84
- WriteObject ( jobId ) ;
85
- }
66
+ isDiscoveryNeed = IsDiscoveryNeeded ( vmName , rgName , out container ) ;
67
+ if ( ( isDiscoveryNeed == true ) || ( container == null ) )
68
+ {
69
+ //Container is not discovered. Throw exception
70
+ throw new NotImplementedException ( ) ;
71
+ }
72
+ }
73
+
74
+ //Container is discovered. Register the container
75
+ List < string > containerNameList = new List < string > ( ) ;
76
+ containerNameList . Add ( container . Name ) ;
77
+ RegisterContainerRequestInput registrationRequest = new RegisterContainerRequestInput ( containerNameList , AzureBackupContainerType . IaasVMContainer . ToString ( ) ) ;
78
+ operationResponse = AzureBackupClient . Container . RegisterAsync ( registrationRequest , GetCustomRequestHeaders ( ) , CmdletCancellationToken ) . Result ;
79
+
80
+ //TODO fix the OperationResponse to JobID conversion
81
+ jobId = operationResponse . OperationId ;
82
+ WriteObject ( jobId ) ;
86
83
} ) ;
87
84
}
88
85
@@ -144,10 +141,9 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, out ContainerInfo c
144
141
bool isDiscoveryNeed = false ;
145
142
//First check if container is discoverd or not
146
143
ListContainerQueryParameter queryParams = new ListContainerQueryParameter ( ) ;
147
- queryParams . ContainerTypeField = String . Empty ; // AzureBackupContainerType.IaasVMContainer.ToString();
144
+ queryParams . ContainerTypeField = AzureBackupContainerType . IaasVMContainer . ToString ( ) ;
148
145
queryParams . ContainerStatusField = String . Empty ;
149
- // queryParams.ContainerFriendlyNameField = vmName;
150
- queryParams . ContainerFriendlyNameField = String . Empty ;
146
+ queryParams . ContainerFriendlyNameField = vmName ;
151
147
string queryString = GetQueryFileter ( queryParams ) ;
152
148
153
149
ListContainerResponse containers = AzureBackupClient . Container . ListAsync ( queryString ,
0 commit comments