Using Managed Identity to Access Azure OpenAI Service

题意:使用托管身份访问 Azure OpenAI 服务

问题背景:

I'm working with Azure OpenAI service, and want to test its Managed Identity support. According to the docs it supports Managed Identity authentication, for example - using a VM.

我正在使用 Azure OpenAI 服务,并希望测试其托管身份(Managed Identity)支持。根据文档,它支持托管身份认证,例如使用虚拟机(VM)。

So I did the following:        因此,我进行了以下操作:

  1. Created a VM in Azure        在 Azure 中创建了一个虚拟机(VM)
  2. Assigned it a managed identity   为其分配了一个托管身份(Managed Identity)
  3. Assigned this identity a "Cognitive Services User" role (as per the docs) on the OpenAI resource   在 OpenAI 资源上为这个身份分配了“Cognitive Services User”角色(根据文档)。
  4. Downloaded Postman to the VM   在虚拟机上下载了 Postman
  5. Tried to access OpenAI API without the API Key (that's the whole point, isn't it?)

尝试在没有 API 密钥的情况下访问 OpenAI API(这不正是重点吗?)

But I keep getting a 401 error.        但我一直收到 401 错误。

What am I missing? With other services, VM with authenticated Managed Identity can access the service (ie. Storage Account, KeyVault). Why isn't it working here?

我遗漏了什么?对于其他服务,带有已认证托管身份的虚拟机可以访问该服务(例如,存储帐户、KeyVault)。为什么在这里不起作用呢?

问题解决:

In order to access Azure Open AI service, you still need an authentication header.

为了访问 Azure OpenAI 服务,你仍然需要一个认证头。

The difference that has a managed identity configured is instead of using api key, you can also use an access token to access the service.

配置了托管身份的区别在于,你可以使用访问令牌而不是 API 密钥来访问服务。

You can take GitHub - openai/openai-python: The official Python library for the OpenAI API as a reference about how to get the access token with managed identity.

你可以参考 GitHub 上的 openai/openai-python: The official Python library for the OpenAI API 了解如何使用托管身份获取访问令牌。

(I am a Microsoft employee working in the Azure SDK team.)

我是一名在 Azure SDK 团队工作的 Microsoft 员工。

  • 21
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值