Azure Vault can't be found when encrypting disk
When I run the following command:
Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $KeyVaultResourceId
I get the following exception:
Set-AzureRmVMDiskEncryptionExtension : Long running operation failed with status 'Failed'.
StartTime: 2/18/2016 5:14:39 PM
EndTime: 2/18/2016 5:16:45 PM
OperationID: *******
Status: Failed
ErrorCode: VMExtensionProvisioningError
ErrorMessage: VM has reported a failure when processing extension 'AzureDiskEncryption'. Error message: "Failed to
configure bitlocker as expected. Exception: An error occurred while sending the request., InnerException:
System.Net.WebException: The remote name could not be resolved: '****.vault.azure.net'
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar), stack trace: at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Azure.KeyVault.KeyVaultCredential.<ProcessHttpRequestAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.KeyVault.Internal.SecretOperations.<SetAsync>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.KeyVault.KeyVaultClient.<>c__DisplayClasscf.<<SetSecretAsync>b__ce>d__d1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.KeyVault.KeyVaultClient.<Do>d__11b`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.KeyVault.KeyVaultClient.<SetSecretAsync>d__d5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.KeyVaultOperations.UploadSecretToKeyVault(String
secretName, Byte[] secretValue, String secretContentType, String wrapKeyURL, String wrapEncryptionAlg, Dictionary`2
tags)
at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.BitlockerExtension.UploadBekToKeyVault(String
volLetter)
at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.BitlockerExtension.GenerateAndUploadProtectorForVolume(
String volLetter)
at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.BitlockerExtension.EnableEncryption()
at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.BitlockerExtension.HandleEncryptionOperations()
at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.BitlockerExtension.OnEnable()".
At line:1 char:1
+ Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMNa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmVMDiskEncryptionExtension], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.Extension.AzureDiskEncryption.SetAzureDiskEncryptionExt
ensionCommand
@singhkay Can you take a look?
Adding @SudhakaraReddyEvuri who owns this cmdlet
Hello Joshua I am sorry about the error. Can you cross check if you added a service principal ($servicePrincipal = New-AzureRmADServicePrincipal -ApplicationId $ADApp.ApplicationId ; ) after creating the AAD app? Alternatively, we created a one touch Pre-Requisites setup script to handle all the setup related to AAD app, KeyVault, permissions etc to enable encryption. We highly recommend you to use this script to create AAD app, KeyVault etc. Here is the script https://github.com/Azure/azure-powershell/blob/dev/src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1 . This script does below things.
- Creates a new AAD app with given name or uses an existing AAD app
- Creates a Resource group with given name or uses existing resource group
- Creates a KeyVault with given name or uses existing vault
- Sets permissions for the AAD app to the KeyVault
- Spits out the parameters need to be input to Set-AzureRmVmDiskEncryptionExtension cmdlet to enable encryption If you uncomment the last two lines, by filling in the VM name, it enables encryption on the VM The script's output can be used as input parameters to templates as well
Sorry, didn't fix it. But that's a wonderful script. We went ahead and deleted everything we'd created previously and then ran this script. Then used the data provided by it and re-ran the command I have in my original post. But unfortunately, I still got the same error.
Hey Joshua
Could you please make sure the VM has appropriate outbound network connectivity and is able to reach AAD & KeyVault end points? Below are the requirements to enable AzureDiskEncryption on the VM from AzureDiskEncryption whitepaper (https://azure.microsoft.com/en-us/documentation/articles/azure-security-disk-encryption/).
To enable Azure Disk Encryption feature, the IaaS VMs must meet the following network endpoint configuration requirements:
• The IaaS VM must be able to connect to Azure Active Directory endpoint [Login.windows.net] to get a token to connect to Azure key vault
• The IaaS VM must be able to connect to Azure Key Vault endpoint to write the encryptions keys to customer key vault
• The IaaS VM must be able to connect to Azure storage endpoint which hosts the Azure extension repository and Azure storage account which hosts the VHD files
Note: If your security policy limits access from Azure VMs to Internet, you can resolve the above URI to which you need connectivity and configure a specific rule to allow outbound connectivity to the IPs.
@joshmouch Hello Joshua, want to check if this issue is resolved or do you need any help further?
@SudhakaraReddyEvuri yes, it is resolved, thank you. It was a DNS issue on the VM. Looking back at the error, that seems obvious now! Your script is awesome, and we'll continue using that going forward.
Hi,
Disk encryption is happening through PS scripts,but its not happening through GUI mode
"Error message": "VM has reported a failure when processing extension 'AzureDiskEncryption'. Error message: "Failed to configure bitlocker as expected. Exception: Operation "set" is not allowed, InnerException: , stack trace: at Microsoft.Azure.KeyVault.KeyVaultClient.
Please help me on this
Hello Rajan, can you cross check if the AAD application ID that you input to the template has permissions to write secrets to the KeyVault? You can set permissions by running the PS cmdlet "Set-AzureRmKeyVaultAccessPolicy -VaultName $keyVaultName -ServicePrincipalName $aadClientID -PermissionsToKeys all -PermissionsToSecrets all;"
Alternatively you can use the AzureDiskEncryption pre-requisites setup script located at https://github.com/Azure/azure-powershell/blob/dev/src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1 to setup the AAD app, KeyVault and permissions.
Hello Rajan, can you cross check if the AAD application ID that you input to the template has permissions to write secrets to the KeyVault? You can set permissions by running the PS cmdlet "Set-AzureRmKeyVaultAccessPolicy -VaultName $keyVaultName -ServicePrincipalName $aadClientID -PermissionsToKeys all -PermissionsToSecrets all;"
Alternatively you can use the AzureDiskEncryption pre-requisites setup script located at https://github.com/Azure/azure-powershell/blob/dev/src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1 to setup the AAD app, KeyVault and permissions.
Thanks Sudhakar
From: rajanbhc [mailto:[email protected]] Sent: Friday, March 18, 2016 12:38 AM To: Azure/azure-powershell [email protected] Cc: Sudhakar Evuri [email protected] Subject: Re: [azure-powershell] Azure Vault can't be found when encrypting disk (#1833)
Hi,
Disk encryption is happening through PS scripts,but its not happening through GUI mode
"Error message": "VM has reported a failure when processing extension 'AzureDiskEncryption'. Error message: "Failed to configure bitlocker as expected. Exception: Operation "set" is not allowed, InnerException: , stack trace: at Microsoft.Azure.KeyVault.KeyVaultClient.
Please help me on this
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHubhttps://github.com/Azure/azure-powershell/issues/1833#issuecomment-198240760
Thanks for your response
if the AAD app is created by script its not replicating in Azure portal.
how to find clientID and Secret for the app which is created by script?
regards, Thiyagarajan P
It seems like github link for AzureDiskEncryptionPreRequisiteSetup.ps1 link is not alive and I am having the same retryable error issue.
Try https://github.com/Azure/azure-powershell/blob/master/src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1