Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, May 9, 2019 7:45 PM
Hi,
I'm trying to upload a custom OS image that I can use to install new VM's, I've been following this guide: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/upload-generalized-managed
When I'll get to the point where I'm supposed to upload the .vhd file with<code class="lang-powershell" data-author-content="$rgName = "myResourceGroup? $urlOfUploadedImageVhd = "https://mystorageaccount.blob.core.windows.net/mycontainer/myUploadedVHD.vhd" Add-AzVhd -ResourceGroupName $rgName -Destination $urlOfUploadedImageVhd ` -LocalFilePath ?C:\Users\Public\Documents\Virtual hard disks\myVHD.vhd? ?>Add-AzVhd, I'll get an error saying: "Add-AzVhd : Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.2.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.17763 N/A Build 17763
PSVersion: 5.1.17763.316
Any idea how to proceed?
Thank you!
<code class="lang-powershell" data-author-content="$rgName = "myResourceGroup? $urlOfUploadedImageVhd = "https://mystorageaccount.blob.core.windows.net/mycontainer/myUploadedVHD.vhd" Add-AzVhd -ResourceGroupName $rgName -Destination $urlOfUploadedImageVhd ` -LocalFilePath ?C:\Users\Public\Documents\Virtual hard disks\myVHD.vhd? ?>
All replies (10)
Friday, May 31, 2019 9:28 PM âś…Answered
Providing an update on this:
Looks like the assembly needed for this cmdlet was left out of recent versions. This issue has been raised with the appropriate team so we should see that fixed in a future release. For now, here is a workaround we can try:
1 - Install Az.Accounts version 1.4.0 in order to get the correct assemblies:
Install-Module Az.Accounts -RequiredVersion 1.4.0 -Force
2 - identify the module path location:
Import-Module Az.Accounts -RequiredVersion 1.4.0 -Force
(Get-Module Az.Accounts | ? { $_.Version -eq '1.4.0' }).Path
3 - Load the assemblies via PowerShell from the Az.Accounts module path (under folder PreloadAssemblies):
[System.Reflection.Assembly]::LoadFrom('C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\1.4.0\PreloadAssemblies\System.Private.ServiceModel.dll') [System.Reflection.Assembly]::LoadFrom('C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\1.4.0\PreloadAssemblies\System.ServiceModel.Primitives.dll')
4 - Retry the Add-AzVhd cmdlet.
The Dev team is looking to push a fix for this sometime next week.
Thursday, May 9, 2019 9:07 PM
Try updating your PowerShell module. The lastest version is now 6 and uses Az instead of AzureRM. So there could be some issues there.
To install the new version, open a PowerShell window as an Administrator and run the following
Get-Module Az
Install-Module Az -AllowClobber
/en-us/powershell/azure/install-az-ps?view=azps-2.0.0
Then try rerunning the commands and let me know the result.
Friday, May 10, 2019 4:49 PM
I am having the same exact issue. Trying to upload Windows 10 Enterprise VHD.
I already tried the Install-Module Az -AllowClobber
Friday, May 10, 2019 5:18 PM
Can you share the full script with outputs as well?
Friday, May 10, 2019 8:38 PM
I ended up uploading the image directly using the Azure portal. It worked and then I was able to create the VM. I got the same error even after I "updated" my module.
Sunday, May 12, 2019 5:28 PM
Picture says more than 1000 words etc. :)
Here is what happens:
You said that "The lastest version is now 6 and uses Az instead of AzureRM. So there could be some issues there." - So isn't Add-AzVhd a Az command then? I thought that the Az prefix would explicitely tell me what are the new Az cmdlets? :O
Monday, May 13, 2019 9:24 PM
Interesting. I see no reason why it shouldn't work. I have tested it and the vhd uploads. Good you can upload via the portal to at least move on.
If you want to dig deeper into this, I would say it is best to open a technical support ticket. If you don't have the ability to open a technical support ticket you can email me at [email protected] and provide me with your AzureSubscriptionID and link to this thread. I can then enable you for that support request.
Friday, May 17, 2019 8:44 AM
Hi,
this can probably fix the issue:
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\1.3.1\PreloadAssemblies\System.ServiceModel.Primitives.dll")
Maybe you need to adjust the path to the dll.
We have the exact same issue since we changed from AzureRm command to Az module.
Regards,
Klaus
Friday, May 31, 2019 6:59 PM
Any update on this thread?
If a answer was useful, please remember to upvote and "Mark as answer" so others in the community can easily find it.
Wednesday, June 5, 2019 2:39 PM
Has there been any update on this, I still appear to be getting the error. I did update the Az PS modules but Az.Accounts did not appear to have an update. I suspect this is causing another issue I am seeing. When trying to create a new image (New-AzImage) using the vhd's uploaded using the add-AzVHD command, I always get the error "New-AzImage : Only blobs formatted as VHDs can be imported."; however if I upload the VHD's through Storage Explorer and then do the New-AzImage it works fine. Please advise. Thanks.
Andrew