douchui4815 2019-08-07 06:07
浏览 23

如何使用服务主体创建Azure事件中心客户端,而不是通过环境变量传递所有参数

Create eventhub client using service principal but not from the environment varibales, using parameters, 1. Create Eventhub client options := getOptions(tenantId, clientId,secret) provider, _ := aad.NewJWTProvider(options) hub, err := eventhubGo.NewHub(namespace, name, provider)

2. The blow function provide the Options,

func getOptions(tenantId string, clientId, secrets string) 
    aad.JWTProviderOption {
    return func(config *aad.TokenProviderConfiguration) error {
        config.TenantID = tenantId
        config.ClientID = clientId
        config.ClientSecret = secrets
        config.Env = &azure.PublicCloud
        return nil
    }
}

Is my approach is correct?

  • 写回答

0条回答 默认 最新

    报告相同问题?