Using Azure openAI key rotation automation

题意:使用 Azure OpenAI 密钥轮换自动化

问题背景:

We are planning to do the Azure OpenAI key rotation automatically. How can we achieve this? Do we have terraform resource for this.

我们计划自动执行 Azure OpenAI 密钥轮换。我们如何实现这一点?是否有相应的 Terraform 资源可用?

python 复制代码
resource "azurerm_cognitive_account" "example" {
  name                = "xxxxx"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  kind                = "OpenAI"

  sku_name = "S0"
}

问题解决:

Firstly, there is no direct resource present for the Open AI key rotation in terraform. Following a workaround on the requirement, I found below approach to make it work.

首先,Terraform 中没有直接用于 OpenAI 密钥轮换的资源。针对这一需求,我找到了一种可行的替代方法,具体如下。

As I mentioned in the comments, use azurerm_cognitive_account resource from terraform by providing kind as an "OpenAI" as shown.

正如我在评论中提到的,可以使用 Terraform 中的 azurerm_cognitive_account 资源,并将 kind 设置为 OpenAI,如图所示。

I tried creating a new open AI account with the below code and the deployment was successful.

我尝试使用以下代码创建一个新的 OpenAI 帐户,部署成功。

python 复制代码
provider  "azurerm"{
  features{}
}
data  "azurerm_resource_group"  "example"  {
    name = "DefaultResourceGroup-EUS"
}
resource  "azurerm_cognitive_account"  "example"  {
    name = "examplesample"
    location = data.azurerm_resource_group.example.location
    resource_group_name = data.azurerm_resource_group.example.name
    kind = "OpenAI"
sku_name = "S0"
}
}

Once it is done, you need to retrieve the keys from the external path. To do that, use data "external" block.

完成后,你需要从外部路径检索密钥。为此,可以使用 data "external" 块。

How to use it: Reference

Sample data block shown below:

示例数据块如下所示:

python 复制代码
data "external" "keys" {
  program = ["sh", "/path/retrieve_sshkey.sh"]
}

Now refer this in the main.tf terraform resource with null_resource block by passing the open ai resource id under triggers block and add a provisioner as well.

现在,在 main.tf Terraform 资源中,通过在 null_resource 块的 triggers 块中传递 OpenAI 资源 ID,并添加一个 provisioner

python 复制代码
resource "null_resource" "samplerotation" {
  triggers = {
    open_ai_resource_id = azurerm_cognitive_account.example.id
    }
provisioner "remote-exec" {
 //write a powershell script here and refer the above keys data block here
 }
}

Alternatively, you can also follow an other approach with the help of key vault. Store all the keys in the key vault and apply the key rotation from there itself.

另外,你也可以使用密钥保管库(Key Vault)采取另一种方法。将所有密钥存储在密钥保管库中,并从那里执行密钥轮换。

To do so, refer the terraform code from SO & for CLI approach refer Github doc.

为此,可以参考来自 Stack Overflow 的 Terraform 代码,并且对于 CLI 方法,可以参考 GitHub 文档。

相关推荐
HyperAI超神经34 分钟前
AI预判等离子体「暴走」,MIT等基于机器学习实现小样本下的等离子体动力学高精度预测
人工智能·神经网络·机器学习·ai·强化学习·可控核聚变·托卡马克
尽兴-3 小时前
【10 分钟!M4 Mac mini 离线部署「私有 ChatGPT」完整实录】
macos·ai·chatgpt·大模型·ollama·私有化
武子康5 小时前
AI-调查研究-105-具身智能 机器人学习数据采集:从示范视频到状态-动作对的流程解析
人工智能·深度学习·机器学习·ai·系统架构·机器人·具身智能
同创永益5 小时前
产品动态 | IStorm Copilot V1.1产品发布
ai·copilot·it·同创永益·数字韧性
GISer_Jing5 小时前
LLM对话框项目技术栈&重难点总结
前端·ai·node.js
非晓为骁7 小时前
AI-Native 能力反思(三):Prompt Engineering 自我提升神器
人工智能·ai·prompt·ai-native·提示词工程
Paraverse_徐志斌7 小时前
RAG架构(检索增强生成)与向量数据库
数据库·ai·llm·embedding·milvus·rag
CoderJia程序员甲7 小时前
GitHub 热榜项目 - 日榜(2025-10-16)
ai·开源·github·ai编程·github热榜
Leinwin9 小时前
Azure Cobalt 100 VM:以卓越性能与能效优化云端工作负载
microsoft·azure
文火冰糖的硅基工坊9 小时前
[嵌入式系统-123]:中高端图形处理器RM Mali-G610 MP4 GPU 是 ARM 公司推出的基于 Valhall 架构 的移动 GPU
arm开发·ai·架构·嵌入式·gpu