How to use MSI for development in visual studio?

后端 未结 4 1323
走了就别回头了
走了就别回头了 2021-01-01 23:31

I need to get access to my Key Vault during development and debugging. Is it possible via using managed service identity? I see that my code can get this credentials when t

相关标签:
4条回答
  • 2021-01-01 23:51

    As of Visual Studio 2017 15.8.something, the extension which juunas mentioned is built into Visual Studio.

    Tools -> Options -> Azure Service Authentication -> Account Selection

    0 讨论(0)
  • 2021-01-02 00:02

    One way is to install the 2.0 Azure CLI, and log in with az login. Then make sure the right subscription is selected with az account set -s "My Azure Subscription name or id".

    Then you will need to make sure the user account you signed in as has access to the Key Vault.

    Now restart Visual Studio, and run the app. It should authenticate successfully.

    Another way is to use the new Visual Studio extension instead of the CLI.

    0 讨论(0)
  • 2021-01-02 00:03

    Here is a Microsoft sample app (Github project) with fairly detailed instructions on how to get up and running with local dev using MSI and Key Vault in the readme

    The key is that when you are debugging locally you're not running as the service principal of the app registered by MSI, but rather as yourself. The Azure CLI az login and az account set commands set the default context for your debugging session. You'll run those commands and then log in to the portal with your Azure identity and give your azure identity access to the key vault.

    0 讨论(0)
  • 2021-01-02 00:06

    Check out the docs for the DefaultAzureCredential (.NET) which explain how to set this up for both development and Managed Identity.

    Below are the links for some of the other supported languages.

    Java

    JavaScript

    Python

    0 讨论(0)
提交回复
热议问题