azure - Go SDK for Azure 如何在没有服务主体的情况下创建虚拟机?

标签 azure go

This sample code from the Go SDK通过部署 ARM 模板创建虚拟机。它要求您包含来自服务主体的 clientId 和 clientSecret。

This sample code from the Go SDK使用适用于 Azure 的 Go SDK 创建虚拟机。它需要订阅 ID,但不需要服务主体(客户端 ID、客户端 key )。它也不会自动创建服务主体。

我认为创建虚拟机需要服务主体,但 GO SDK 示例能够在不指定服务主体的情况下创建虚拟机。我对服务主体和虚拟机缺少什么?

最佳答案

它使用NewDefaultAzureCredential ,此类从环境中检索身份验证信息(例如 azure CLI、环境变量)- see docs

func connectionAzure() (azcore.TokenCredential, error) {
    cred, err := azidentity.NewDefaultAzureCredential(nil)
    if err != nil {
        return nil, err
    }
    return cred, nil
}

enter image description here

关于azure - Go SDK for Azure 如何在没有服务主体的情况下创建虚拟机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74976179/

相关文章:

c# - Azure WCF 服务在 blob 存储文件上出现错误

c++ - ESP32 OTA 更新在启动时不断崩溃

go - 无法 `syscall.Kill()` 一个守护进程

go - 如何使用golang查询将数据流传输到Cassandra

azure - FTP文件上传错误: An exception occurred during a WebClient request. InnerException : This method is not supported.(参数 'value')

azure - 是否可以使用arm部署Azure Synapse工作区角色?

azure - 使用 ARM 完全自动化 Microsoft bot 框架部署(应用程序设置被删除且功能缺失)

go - slice 声明和初始化之间的区别

struct - 如何在控制台中打印结构变量?

go - 为什么闭包中本地分配的变量在外部分配时的工作方式不同?