title: unable to get the secret / certificate from Azure Key Vault using python | 'KeyVaultManagementClient' object has no attribute 'get_secret'
body: <p>Thanks in advance, I'm trying to create a VM using python. At the time of deployment it'll check for certificate present in key vault and copy it in the VM.</p>
  
  <p>I'm doing this with by following below article</p>
  
  <p><a href="https://azure.microsoft.com/en-in/resources/samples/key-vault-python-deploy-certificates-to-vm/" rel="nofollow noreferrer">https://azure.microsoft.com/en-in/resources/samples/key-vault-python-deploy-certificates-to-vm/</a></p>
  
  <p>The issue here is, the above example was performed by login using the application id, secret method and I'm login using the device auth.</p>
  
  <p>I wanted to use ADAL or device auth method in which it'll ask us to login on to the azure portal and then type the auth code and then login. It'll pass the credentials to the current session.
  I'm using interactive way of authentication and not using the non interactive way of client id and secrets</p>
  
  <p>I'm getting the error <code>'KeyVaultManagementClient' object has no attribute 'get_secret'</code> on the function "get_certificates". Is there any function which gets the certificate/secrets using my way of interactive logon? or this is only available with the application id and secret method.</p>
  
  <pre><code>from azure.common.credentials import ServicePrincipalCredentials
  from azure.mgmt.resource import ResourceManagementClient
  from azure.mgmt.compute import ComputeManagementClient
  from azure.mgmt.network import NetworkManagementClient
  from azure.mgmt.compute.models import DiskCreateOption
  from azure.mgmt.network.v2017_03_01.models import NetworkSecurityGroup
  from azure.mgmt.network.v2017_03_01.models import SecurityRule
  import azure.mgmt.network.models
  from msrestazure.azure_active_directory import AADTokenCredentials
  from azure.mgmt.keyvault import KeyVaultManagementClient
  from azure.mgmt.datalake.analytics.job import DataLakeAnalyticsJobManagementClient
  from azure.mgmt.datalake.analytics.job.models import JobInformation, JobState, USqlJobProperties
  import adal, uuid, time
  
  
  SUBSCRIPTION_ID = 'xxx-xxxx-xxxx-xxxx-xxxx'
  GROUP_NAME = 'RAH-AQ'
  Vault_Name = 'aqrahkeyvault'
  LOCATION = ''
  certificate_as_secret = ''
  
  def authenticate_device_code():
      """
      Authenticate the end-user using device auth.
      """
  
      authority_host_uri = 'https://login.microsoftonline.com'
      tenant = 'xxxx-xxxx-xxxx-xxxx-xxxx'
      authority_uri = authority_host_uri + '/' + tenant
      resource_uri = 'https://management.core.windows.net/'
      client_id = '04b07795-8ddb-461a-bbee-02f9e1bf7b46'
  
      context = adal.AuthenticationContext(authority_uri, api_version=None)
      code = context.acquire_user_code(resource_uri, client_id)
      print(code['message'])
      mgmt_token = context.acquire_token_with_device_code(resource_uri, code, client_id)
      credentials = AADTokenCredentials(mgmt_token, client_id)
  
      return credentials
  
  
  
  def get_keyvault(kv_client):
    myvault = kv_client.vaults.get(resource_group_name=GROUP_NAME,vault_name= Vault_Name)
  
    return myvault
  
  
  def get_certificates(myvault):
      global certificate_as_secret
      certificate_as_secret = kv_client.get_secret(
          myvault.properties.vault_uri,
          staticwebsite,
          "" # Latest version
      )
  
  
  if __name__ == "__main__":
      credentials = authenticate_device_code()
  
  resource_group_client = ResourceManagementClient(
      credentials, 
      SUBSCRIPTION_ID
  )
  network_client = NetworkManagementClient(
      credentials, 
      SUBSCRIPTION_ID
  )
  compute_client = ComputeManagementClient(
      credentials, 
      SUBSCRIPTION_ID
  )
  
  kv_client = KeyVaultManagementClient(
      credentials,
      SUBSCRIPTION_ID
  )
  
  
  
  creation_result_keyvault = get_keyvault(kv_client)
  print("------------------------------------------------------")
  print(creation_result_keyvault)
  
  creation_result_certificates = get_certificates(creation_result_keyvault)
  print("------------------------------------------------------")
  print(creation_result_certificates)
  </code></pre>