I am trying to convert the example code at https://learn.microsoft.com/en-us/azure/key-vault/tutorial-net-create-vault-azure-web-app to VB.net and use it to access a secret that I have stored in my Azure Key Vault. I used the converter at http://converter.telerik.com/.
The converted code gives an error saying "Delegate 'KeyVaultClient.AuthenticationCallback' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor."
This is the converted code:
Imports Microsoft.Azure.KeyVault
Imports Microsoft.Azure.Services.AppAuthentication
Imports Microsoft.Azure.KeyVault.Models
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim azureServiceTokenProvider As AzureServiceTokenProvider = New AzureServiceTokenProvider
Dim keyVaultClient As KeyVaultClient = New KeyVaultClient(New KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback))
Dim secret As String = keyVaultClient.GetSecretAsync("https://<YourKeyVaultName>.vault.azure.net/secrets/AppSecret").ConfigureAwait(False)
TextBox1.Text = secret.Value
End Sub
I would like to know the code necessary to access a secret in my key vault. I have given my app all permissions to access the vault in the Azure portal and I am logged in with my Azure account in VS2017 and I have been at this for 3 days and cannot find any VB examples for accessing key vault that are current.