Using Azure openAI key rotation automation

ops/2024/9/25 16:36:01/
aidu_pl">

题意:使用 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 资源可用?

resource "azurerm_cognitive_account" "example" {name                = "xxxxx"location            = azurerm_resource_group.example.locationresource_group_name = azurerm_resource_group.example.namekind                = "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 帐户,部署成功。

provider  "azurerm"{features{}
}
data  "azurerm_resource_group"  "example"  {name = "DefaultResourceGroup-EUS"
}
resource  "azurerm_cognitive_account"  "example"  {name = "examplesample"location = data.azurerm_resource_group.example.locationresource_group_name = data.azurerm_resource_group.example.namekind = "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:

示例数据块如下所示:

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

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 文档。


http://www.ppmy.cn/ops/97318.html

相关文章

C语言与Python的区别

一、言语类型Python是一种基于解说器的言语,解说器会逐行读取代码;首先将Python编译为字节码,然后由大型C程序解说;C是一种编译言语,完好的源代码将直接编译为机器代码,由CPU直接履行。 二、内存办理Python…

企业级Web服务器性能优化实践指南

目录 引言 一、 Web服务器基础与发展历程 1.互联网与Web服务发展简史 2. Apache与Nginx的性能对比 2.1 Apache服务器 2.2 Nginx服务器 3. 用户访问体验的重要性 3.1 用户速度体验原则 3.2 影响用户体验的因素 4. 服务端I/O流程与性能 4.1 I/O基本概念 4.2 磁盘I/O …

Springboot整合Flowable【查阅众多资料,功能完整,亲身验证】

一、搭建一个基于maven的基础框架 1.环境说明:JDK11、Mysql8 2.项目结构概览: 二、项目相关代码及配置 1.pom.xml配置 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"…

Rust 面向对象编程

Rust 面向对象编程 概述 Rust 是一种系统编程语言&#xff0c;以其安全性、并发性和性能而闻名。尽管 Rust 并不是传统意义上的面向对象编程&#xff08;OOP&#xff09;语言&#xff0c;但它提供了一些机制和模式&#xff0c;使得可以在 Rust 中实现面向对象的设计理念。本文…

React 使用ref属性调用子组件方法(也可以适用于父子传参)

注意&#xff1a;①需使用hooks函数组件 ②使用了antDesign组件库&#xff08;可不用&#xff09; 如何使用 父组件代码 import React, { useState, useRef, useEffect } from react; import { Button } from antd; import Child from ./components/child;export defau…

esbuild的build.onResolve深入解析:args参数全揭秘

在前端构建工具中&#xff0c;esbuild以其极快的打包和压缩速度脱颖而出。它提供了一个强大的构建API&#xff0c;其中build.onResolve事件是处理模块解析的关键环节。本文将深入解析build.onResolve事件&#xff0c;特别是其args参数&#xff0c;帮助开发者了解如何在解析模块…

使用Xshell6远程登录Linux 服务器--远程上传下载文件Xftp6的使用

&#x1f600;前言 本篇博文是关于Linux 实操篇-使用Xshell6远程登录Linux 服务器–远程上传下载文件Xftp6的使用&#xff0c;希望你能够喜欢 &#x1f3e0;个人主页&#xff1a;晨犀主页 &#x1f9d1;个人简介&#xff1a;大家好&#xff0c;我是晨犀&#xff0c;希望我的文章…

掌握Objective-C文本对齐:NSTextTab与NSTextTable的高级应用

标题&#xff1a;掌握Objective-C文本对齐&#xff1a;NSTextTab与NSTextTable的高级应用 在Objective-C中&#xff0c;NSTextTab和NSTextTable提供了强大的文本制表和表格布局功能&#xff0c;它们是文本排版中不可或缺的工具。本文将深入探讨这两个API如何在实际开发中处理文…