Create Virtual Machine(VM) in Azure throws “Long running operation failed with status ‘Failed’.” through PowerShell

I was following the article SharePoint Server 2016 dev/test environment in Azure to create a SharePoint Server 2016 environment in Azure.

I reached the step to create the Virtual Machine that will be used as the domain controller using the cmdlet below

New-AzureRMVM -ResourceGroupName $rgName -Location $locName -VM $vm

After waiting for several minutes I decided to cancel the operation. When I retried the same cmdlet, I got the following error.

New-AzureRMVM -ResourceGroupName $rgName -Location $locName -VM $vm -Verbose
VERBOSE: Performing the operation "New" on target "adVM".
New-AzureRMVM : Long running operation failed with status 'Failed'.
ErrorCode: VMAgentStatusCommunicationError
ErrorMessage: VM 'adVM' has not reported status for VM agent or extensions. 
Please verify the VM has a running VM agent, and can establish 
outbound connections to Azure storage.
StartTime: 18/11/2016 15:42:46
EndTime: 18/11/2016 15:42:46
OperationID: f1ecb302-9da9-4a76-9b0c-463b5e89c41c
Status: Failed
At line:1 char:1
+ New-AzureRMVM -ResourceGroupName $rgName -Location $locName -VM $vm -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException
 + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

I spent a while trying to understand what the error message meant. In that scenerio the error message was thrown because the VM requested was created successfully even though I interrupted the operation before. The error thrown was to prevent creating another VM with the same details.

When I created the second VM, I waited long enough till the success message was displayed.



Using PnP PowerShell to export and import Taxonomy

PnP provides export taxonomy cmdlet which allows to export all term groups, term sets, terms and child terms to a file with one line of code

Connect-SPOnline -Url <siteurl> -CurrentCredentials 
Export-SPOTaxonomy -IncludeID -Path "C:\temp\Metadata\terms.txt"

PnP also provides an equivalent import taxonomy cmdlet to import all term groups, term sets, terms and child terms from a file with one line of code

Connect-SPOnline -Url <siteurl> -CurrentCredentials
Import-SPOTaxonomy -Path "C:\temp\Metadata\terms.txt"

However if IncludeId switch parameter is used with the export, the import would fail if the October 2016 PnP PowerShell release is used.

The error message appears

Import-SPOTaxonomy : Exception on line 5: Failed to read from or write to database. 
Refresh and try again. If the problem persists, please contact the administrator

I decided to enable Trace on the PnP to get debug messages using the Set-SPOTraceLog

  Set-SPOTraceLog -On -Level Debug

Debug messages appear to monitor progress of execution but was not helpful.


I tried to google the message, found out that the error happened as the code is trying to create a term or term set with an unique identifier (GUID)  which already exists in the taxonomy store.

I inspected the taxonomy file exported and found that terms having child terms were wrongly formatted.In the example below the term group EDRMS is repeated 3 times.

EDRMS;#383eab6e-a944-430d-9a18-f8b872322c2c|EDRMS;#383eab6e-a944-430d-9a18-f8b872322c2c|Directorate;#a99db510-121a-407b-87ec-0b4911e59469|EDRMS;#383eab6e-a944-430d-9a18-f8b872322c2c|Directorate;#a99db510-121a-407b-87ec-0b4911e59469|Finance;#fbab08b3-bc7d-4363-a1c4-1f5d4a466b07|Credit and Collections;#0ec6cefe-c92c-4dfe-81d4-1fe56183f8a2

The Export-SPOTaxonomy was wrongly formatting child terms in the export file.

I raised the issue 532 on PnP PowerShell project.

However I was not sure how quick the issue was going to get fixed so decided to debug PnP powershell command  and found that the issue was with the core PnP project . I fixed it with pull request Taxonomy import export which got merged into pull request Fixed issue with subterms not exported correctly when using ExportAll” .

With the PnP PowerShell November 2016 release, you will be able to use PnP to import and export taxonomy.