From 15fe45b7c3695f14ccd048ddc97f8e3dbab9fd0e Mon Sep 17 00:00:00 2001 From: Brian Pickens <3659859+brian-pickens@users.noreply.github.com> Date: Wed, 12 Jun 2024 02:11:03 -0500 Subject: [PATCH] Example authenticating with AzureAD (#135) * Use azuread mssql driver * spacing --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index b40880e..8f335f7 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,19 @@ dsn := "sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" db, err := gorm.Open(sqlserver.Open(dsn), &gorm.Config{}) ``` +## Azure AD Auth + +```go +import ( + "github.com/microsoft/go-mssqldb/azuread" + "gorm.io/driver/sqlserver" + "gorm.io/gorm" +) + +// github.com/microsoft/go-mssqldb +dsn := "sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" +dialector := &sqlserver.Dialector{Config: &sqlserver.Config{DSN: dsn, DriverName: azuread.DriverName}} +db, err := gorm.Open(dialector, &gorm.Config{}) +``` + Checkout [https://gorm.io](https://gorm.io) for details.