[{"data":1,"prerenderedAt":5922},["Reactive",2],{"navigation":3,"aAII9Cz3yR":204,"tags-Azure SDK":397},[4,192,200],{"title":5,"_path":6,"children":7,"icon":191},"Blog","/posts",[8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,92,95,98,101,104,107,110,113,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,176,179,182,185,188],{"title":9,"_path":10},"Testing your API with REST Client","/posts/testing-your-api-with-rest-client",{"title":12,"_path":13},"HTML templating in Xamarin","/posts/html-templating-in-xamarin",{"title":15,"_path":16},"Goodbye Azure Portal, Welcome Azure CLI","/posts/welcome-azure-cli",{"title":18,"_path":19},"Coming across Gitpod","/posts/gitpod",{"title":21,"_path":22},"Handle token retrieval while querying an API","/posts/delegating-handler",{"title":24,"_path":25},"Clean up your local git branches.","/posts/cleaning-git-branches",{"title":27,"_path":28},"Automate configuration of Teams Tab SSO with PowerShell.","/posts/teams-sso-powershell",{"title":30,"_path":31},"How to do a technology watch? - Part 1","/posts/technology-watch-part1",{"title":33,"_path":34},"How to do a technology watch? - Part 2","/posts/technology-watch-part2",{"title":36,"_path":37},"You almost no longer need Key Vault references for Azure Functions.","/posts/azure-functions-custom-configuration",{"title":39,"_path":40},"How to do a technology watch? - Part 3","/posts/technology-watch-part3",{"title":42,"_path":43},"Forget DevOps, the future is already here!","/posts/devops-future",{"title":45,"_path":46},"Week 9, 2021 - Tips I learned this week","/posts/w09-2021-tips-learned-this-week",{"title":48,"_path":49},"Week 12, 2021 - Tips I learned this week","/posts/w12-2021-tips-learned-this-week",{"title":51,"_path":52},"Week 14, 2021 - Tips I learned this week","/posts/w14-2021-tips-learned-this-week",{"title":54,"_path":55},"Once upon a time in .NET","/posts/once-upon-a-time-in-dotnet",{"title":57,"_path":58},"Install your applications with winget","/posts/winget-import",{"title":60,"_path":61},"Customize your applications when installing them with winget","/posts/winget-override",{"title":63,"_path":64},"Week 22, 2021 - Tips I learned this week","/posts/w22-2021-tips-learned-this-week",{"title":66,"_path":67},"How to connect to an Azure SQL Database from C# using Azure AD","/posts/sqlclient-active-directory-authent",{"title":69,"_path":70},"Producing packages for Windows Package Manager","/posts/wingetcreate",{"title":72,"_path":73},"4 tips about GitHub Actions environment variables and contexts","/posts/github-actions-var-and-context",{"title":75,"_path":76},"AzureWebJobsStorage, the secret you don't need in your Function App.","/posts/azure-functions-without-azurewebjobsstorage",{"title":78,"_path":79},"ASP.NET Core - Lost in configuration","/posts/lost-in-configuration",{"title":81,"_path":82},"Week 39, 2021 - Tips I learned this week","/posts/w39-2021-tips-learned-this-week",{"title":84,"_path":85},"Week 41, 2021 - Tips I learned this week","/posts/w41-2021-tips-learned-this-week",{"title":87,"_path":88},"Migrating and open-sourcing my blog","/posts/migrating-blog",{"title":90,"_path":91},"Week 45, 2021 - Tips I learned this week","/posts/w45-2021-tips-learned-this-week",{"title":93,"_path":94},"Organize your GitHub stars with Astral","/posts/astral",{"title":96,"_path":97},"Pulumi with an Azure Blob Storage backend","/posts/pulumi-azure-backend",{"title":99,"_path":100},"IaC Hot Reload with Pulumi Watch","/posts/pulumi-watch",{"title":102,"_path":103},"Week 2, 2022 - Tips I learned this week","/posts/w02-2022-tips-learned-this-week",{"title":105,"_path":106},"Week 3, 2022 - Tips I learned this week","/posts/w03-2022-tips-learned-this-week",{"title":108,"_path":109},"Week 5, 2022 - Tips I learned this week","/posts/w05-2022-tips-learned-this-week",{"title":111,"_path":112},"How to provision an Azure SQL Database with Active Directory authentication","/posts/sqldatabase-active-directory-authent",{"title":114,"_path":115},"Why will I choose Pulumi over Terraform for my next project?","/posts/pulumi-vs-terraform",{"title":117,"_path":118},"Week 19, 2022 - Tips I learned this week","/posts/w19-2022-tips-learned-this-week",{"title":120,"_path":121},"Week 20, 2022 - Tips I learned this week","/posts/w20-2022-tips-learned-this-week",{"title":123,"_path":124},"Keeping secrets secure when using API Clients","/posts/http-clients-secrets",{"title":126,"_path":127},"What made me want to be a developer?","/posts/be-a-developer",{"title":129,"_path":130},"What can we do when stuck with a programming problem?","/posts/get-unstuck",{"title":132,"_path":133},"How did I automate the setup of my developer Windows laptop?","/posts/automate-developer-machine",{"title":135,"_path":136},"Discussion about API clients","/posts/http-clients",{"title":138,"_path":139},"Week 46, 2022 - Tips I learned this week","/posts/w46-2022-tips-learned-this-week",{"title":141,"_path":142},"When Pulumi met Nuke: a .NET love story","/posts/when-pulumi-met-nuke",{"title":144,"_path":145},"A year of learning and sharing - Dev Retro 2022","/posts/2022-retro",{"title":147,"_path":148},"Perform Dynamic Execution of an npm Package","/posts/pnpm-dlx",{"title":150,"_path":151},"Manage multiple Node.js versions","/posts/pnpm-env",{"title":153,"_path":154},"Introducing the Vue.js CI/CD series","/posts/vuecicd-introduction",{"title":156,"_path":157},"Execute commands using your project dependencies","/posts/pnpm-exec",{"title":159,"_path":160},"Vue.js CI/CD: Continuous Integration","/posts/vuecicd-ci",{"title":162,"_path":163},"Who is using pnpm?","/posts/pnpm-who-is-using",{"title":165,"_path":166},"Create an Azure-Ready GitHub Repository using Pulumi","/posts/azure-ready-github-repository",{"title":168,"_path":169},"Deploying to Azure from Azure DevOps without secrets","/posts/ado-workload-identity-federation",{"title":171,"_path":172},"Effortlessly Configure GitHub Repositories for Azure Deployment via OIDC","/posts/scripting-azure-ready-github-repository",{"title":174,"_path":175},"Playing with the .NET 8 Web API template","/posts/playing-with-dotnet8",{"title":177,"_path":178},"Another year of sharing and learning - Dev Retro 2023","/posts/2023-retro",{"title":180,"_path":181},"Week 4, 2024 - Tips I learned this week","/posts/w04-2024-tips-learned-this-week",{"title":183,"_path":184},"Using dependency injection with Azure .NET SDK","/posts/azure-sdk-di",{"title":186,"_path":187},"Having Fun With IT Event Calendars","/posts/it-event-calendars",{"title":189,"_path":190},"Call your Azure AD B2C protected API with authenticated HTTP requests from your JetBrains IDE","/posts/http-clients-oauth2","i-heroicons-newspaper",{"title":193,"_path":194,"children":195,"icon":199},"Goodies","/goodies",[196],{"title":197,"_path":198},"My Git Cheat Sheet","/goodies/gitcheatsheet","i-heroicons-gift-solid",{"title":201,"_path":202,"icon":203},"About","/about","i-heroicons-user-circle-solid",[205,207,209,211,214,217,220,223,226,229,231,234,237,240,242,244,247,250,253,255,258,261,264,267,270,273,276,279,282,285,287,289,292,294,297,300,303,305,308,310,313,316,319,322,325,327,329,332,335,338,341,344,347,350,353,356,359,361,363,366,369,372,375,377,380,383,385,388,391,394],[206,206],"tooling",[208,208],"vscode",[210,210],"rest",[212,213],"http","HTTP",[215,216],"razor","Razor",[218,219],"xamarin","Xamarin",[221,222],"templating","Templating",[224,225],"azure-cli","Azure CLI",[227,228],"azure","Azure",[230,230],"shell",[232,233],"github","GitHub",[235,236],"asp-net-core","ASP.NET Core",[238,239],"net",".NET",[241,241],"git",[243,243],"nushell",[245,246],"microsoft-teams","Microsoft Teams",[248,249],"powershell","PowerShell",[251,252],"azure-active-directory","Azure Active Directory",[254,254],"learning",[256,257],"azure-functions","Azure Functions",[259,260],"azure-key-vault","Azure Key Vault",[262,263],"configuration","Configuration",[265,266],"devops","DevOps",[268,269],"it","IT",[271,272],"tips-learned-this-week","tips learned this week",[274,275],"windows-terminal","Windows Terminal",[277,278],"azure-pipelines","Azure Pipelines",[280,281],"application-insights","Application Insights",[283,284],"azure-iot","Azure IoT",[286,286],"records",[288,288],"refit",[290,291],"development-box-setup","development box setup",[293,293],"winget",[295,296],"package-manager","package manager",[298,299],"azure-sql-database","Azure SQL Database",[301,302],"azure-sdk","Azure SDK",[304,304],"wingetcreate",[306,307],"github-actions","GitHub Actions",[309,309],"jq",[311,312],"pulumi","Pulumi",[314,315],"iac","IaC",[317,318],"azure-storage","Azure Storage",[320,321],"azure-signalr","Azure SignalR",[323,324],"visio","Visio",[326,326],"csharp",[328,328],"jest",[330,331],"statiq","Statiq",[333,334],"open-source","open source",[336,337],"visual-studio","Visual Studio",[339,340],"vue-js","Vue.js",[342,343],"azure-devops","Azure DevOps",[345,346],"vite","Vite",[348,349],"code-analysis","Code analysis",[351,352],"diagram","Diagram",[354,355],"terraform","Terraform",[357,358],"typescript","TypeScript",[360,360],"thoughts",[362,362],"pnpm",[364,365],"nuke","Nuke",[367,368],"pipelines","Pipelines",[370,371],"cicd","CI/CD",[373,374],"openid-connect","OpenID Connect",[376,376],"security",[378,379],"github-cli","GitHub CLI",[381,382],"microsoft-entra-id","Microsoft Entra ID",[384,384],"advent",[386,387],"finops","FinOps",[389,390],"anglesharp","AngleSharp",[392,393],"oauth2","OAuth2",[395,396],"azure-ad-b2c","Azure AD B2C",[398,3488],{"_path":184,"_dir":399,"_draft":400,"_partial":400,"_locale":401,"title":183,"description":402,"lead":403,"date":404,"image":405,"badge":407,"tags":409,"ImageAttribution":410,"body":411,"_type":3483,"_id":3484,"_source":3485,"_file":3486,"_extension":3487},"posts",false,"","I love how the Azure SDKs have evolved over the years. In the past, there was no consistency between the various Azure SDKs. However, that's not longer the case (at least for most Azure libraries), as they now adhere to the same principles and follow a set of well-defined guidelines.","Register your Azure clients the proper way","2024-02-19T00:00:00.000Z",{"src":406},"/images/apple-di.webp",{"label":408},"Development",[228,302,239],"Picture of \u003Ca href=\"https://unsplash.com/fr/@sarabakhshi\">Sara Bakhshi\u003C/a> on \u003Ca href=\"https://unsplash.com/fr/photos/pomme-fruit-avec-des-seringues-en-plastique-MfnX4XtGnvU\">Unsplash\u003C/a>",{"type":412,"children":413,"toc":3475},"root",[414,433,452,457,476,481,488,502,507,522,922,942,1380,1419,1425,1439,1719,1724,1749,1755,1767,2037,2050,2476,2487,2501,2507,2520,2525,2767,2772,2942,2948,2970,3014,3430,3442,3448,3464,3469],{"type":415,"tag":416,"props":417,"children":418},"element","p",{},[419,422,431],{"type":420,"value":421},"text","I love how the Azure SDKs have evolved over the years. In the past, there was no consistency between the various Azure SDKs. However, that's not longer the case (at least for most Azure libraries), as they now adhere to the same principles and follow a set of well-defined ",{"type":415,"tag":423,"props":424,"children":428},"a",{"href":425,"rel":426},"https://azure.github.io/azure-sdk/general_introduction.html",[427],"nofollow",[429],{"type":420,"value":430},"guidelines",{"type":420,"value":432},".",{"type":415,"tag":434,"props":435,"children":437},"callout",{"icon":436},"i-heroicons-light-bulb",[438],{"type":415,"tag":416,"props":439,"children":440},{},[441,443,450],{"type":420,"value":442},"You can learn more about these guidelines and how the Azure .NET SDKs work in this ",{"type":415,"tag":423,"props":444,"children":447},{"href":445,"rel":446},"https://youtu.be/v36NXLU3TLY?si=L8e1ic898kDCisJ7",[427],[448],{"type":420,"value":449},"video",{"type":420,"value":451}," from 2021 which is I think still relevant today.",{"type":415,"tag":416,"props":453,"children":454},{},[455],{"type":420,"value":456},"Having consistency between libraries, it's easier to handle things like authentication and dependency injection consistently when you are using multiple Azure SDKs in your project.",{"type":415,"tag":416,"props":458,"children":459},{},[460,462,474],{"type":420,"value":461},"One aspect often overlooked by people using Azure SDKs is the use of ",{"type":415,"tag":423,"props":463,"children":466},{"href":464,"rel":465},"https://www.nuget.org/packages/Microsoft.Extensions.Azure",[427],[467],{"type":415,"tag":468,"props":469,"children":471},"code",{"className":470},[],[472],{"type":420,"value":473},"Microsoft.Extensions.Azure",{"type":420,"value":475},". This package facilitates registering and configuring the service clients for interacting with Azure APIs.",{"type":415,"tag":416,"props":477,"children":478},{},[479],{"type":420,"value":480},"Let's see why using this package could be beneficial for your project.",{"type":415,"tag":482,"props":483,"children":485},"h2",{"id":484},"avoid-making-mistakes-when-registering-service-clients",[486],{"type":420,"value":487},"Avoid making mistakes when registering service clients",{"type":415,"tag":416,"props":489,"children":490},{},[491,493,500],{"type":420,"value":492},"It's mentioned in the ",{"type":415,"tag":423,"props":494,"children":497},{"href":495,"rel":496},"https://learn.microsoft.com/en-us/dotnet/azure/sdk/dependency-injection?view=azure-dotnet&tabs=web-app-builder",[427],[498],{"type":420,"value":499},"documentation",{"type":420,"value":501}," to use this package for dependency injection with the Azure SDK for .NET. Still, many people don't read the documentation and manually register the Azure service clients.",{"type":415,"tag":416,"props":503,"children":504},{},[505],{"type":420,"value":506},"It's not a problem in itself if you know what you are doing. Otherwise,",{"type":415,"tag":508,"props":509,"children":510},"ul",{},[511,517],{"type":415,"tag":512,"props":513,"children":514},"li",{},[515],{"type":420,"value":516},"you might choose the wrong lifetime for the Azure service clients, they must be singleton",{"type":415,"tag":512,"props":518,"children":519},{},[520],{"type":420,"value":521},"you may forget to register a dependency that is needed for your use of the SDK",{"type":415,"tag":523,"props":524,"children":527},"pre",{"className":525,"code":526,"language":326,"meta":401,"style":401},"language-csharp shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","using Azure.Identity;\nusing DIWithAzureSDK;\nusing Microsoft.Extensions.Azure;\n\nvar builder = Host.CreateApplicationBuilder(args);\nbuilder.Services.AddHostedService\u003CWorker>();\nbuilder.Services.AddAzureClients(clientBuilder =>\n{\n    clientBuilder.AddBlobServiceClient(new Uri(\"https://stdiwithazuresdk.blob.core.windows.net/\"));\n    clientBuilder.UseCredential(new DefaultAzureCredential());\n});\n\nvar host = builder.Build();\nhost.Run();\n",[528],{"type":415,"tag":468,"props":529,"children":530},{"__ignoreMap":401},[531,564,581,615,625,675,717,756,765,817,848,857,865,900],{"type":415,"tag":532,"props":533,"children":536},"span",{"class":534,"line":535},"line",1,[537,543,549,554,559],{"type":415,"tag":532,"props":538,"children":540},{"style":539},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[541],{"type":420,"value":542},"using",{"type":415,"tag":532,"props":544,"children":546},{"style":545},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[547],{"type":420,"value":548}," Azure",{"type":415,"tag":532,"props":550,"children":552},{"style":551},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[553],{"type":420,"value":432},{"type":415,"tag":532,"props":555,"children":556},{"style":545},[557],{"type":420,"value":558},"Identity",{"type":415,"tag":532,"props":560,"children":561},{"style":551},[562],{"type":420,"value":563},";\n",{"type":415,"tag":532,"props":565,"children":567},{"class":534,"line":566},2,[568,572,577],{"type":415,"tag":532,"props":569,"children":570},{"style":539},[571],{"type":420,"value":542},{"type":415,"tag":532,"props":573,"children":574},{"style":545},[575],{"type":420,"value":576}," DIWithAzureSDK",{"type":415,"tag":532,"props":578,"children":579},{"style":551},[580],{"type":420,"value":563},{"type":415,"tag":532,"props":582,"children":584},{"class":534,"line":583},3,[585,589,594,598,603,607,611],{"type":415,"tag":532,"props":586,"children":587},{"style":539},[588],{"type":420,"value":542},{"type":415,"tag":532,"props":590,"children":591},{"style":545},[592],{"type":420,"value":593}," Microsoft",{"type":415,"tag":532,"props":595,"children":596},{"style":551},[597],{"type":420,"value":432},{"type":415,"tag":532,"props":599,"children":600},{"style":545},[601],{"type":420,"value":602},"Extensions",{"type":415,"tag":532,"props":604,"children":605},{"style":551},[606],{"type":420,"value":432},{"type":415,"tag":532,"props":608,"children":609},{"style":545},[610],{"type":420,"value":228},{"type":415,"tag":532,"props":612,"children":613},{"style":551},[614],{"type":420,"value":563},{"type":415,"tag":532,"props":616,"children":618},{"class":534,"line":617},4,[619],{"type":415,"tag":532,"props":620,"children":622},{"emptyLinePlaceholder":621},true,[623],{"type":420,"value":624},"\n",{"type":415,"tag":532,"props":626,"children":628},{"class":534,"line":627},5,[629,635,640,645,650,654,660,665,670],{"type":415,"tag":532,"props":630,"children":632},{"style":631},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[633],{"type":420,"value":634},"var",{"type":415,"tag":532,"props":636,"children":637},{"style":631},[638],{"type":420,"value":639}," builder",{"type":415,"tag":532,"props":641,"children":642},{"style":551},[643],{"type":420,"value":644}," =",{"type":415,"tag":532,"props":646,"children":647},{"style":545},[648],{"type":420,"value":649}," Host",{"type":415,"tag":532,"props":651,"children":652},{"style":551},[653],{"type":420,"value":432},{"type":415,"tag":532,"props":655,"children":657},{"style":656},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[658],{"type":420,"value":659},"CreateApplicationBuilder",{"type":415,"tag":532,"props":661,"children":662},{"style":551},[663],{"type":420,"value":664},"(",{"type":415,"tag":532,"props":666,"children":667},{"style":545},[668],{"type":420,"value":669},"args",{"type":415,"tag":532,"props":671,"children":672},{"style":551},[673],{"type":420,"value":674},");\n",{"type":415,"tag":532,"props":676,"children":678},{"class":534,"line":677},6,[679,684,688,693,697,702,707,712],{"type":415,"tag":532,"props":680,"children":681},{"style":545},[682],{"type":420,"value":683},"builder",{"type":415,"tag":532,"props":685,"children":686},{"style":551},[687],{"type":420,"value":432},{"type":415,"tag":532,"props":689,"children":690},{"style":545},[691],{"type":420,"value":692},"Services",{"type":415,"tag":532,"props":694,"children":695},{"style":551},[696],{"type":420,"value":432},{"type":415,"tag":532,"props":698,"children":699},{"style":656},[700],{"type":420,"value":701},"AddHostedService",{"type":415,"tag":532,"props":703,"children":704},{"style":551},[705],{"type":420,"value":706},"\u003C",{"type":415,"tag":532,"props":708,"children":709},{"style":631},[710],{"type":420,"value":711},"Worker",{"type":415,"tag":532,"props":713,"children":714},{"style":551},[715],{"type":420,"value":716},">();\n",{"type":415,"tag":532,"props":718,"children":720},{"class":534,"line":719},7,[721,725,729,733,737,742,746,751],{"type":415,"tag":532,"props":722,"children":723},{"style":545},[724],{"type":420,"value":683},{"type":415,"tag":532,"props":726,"children":727},{"style":551},[728],{"type":420,"value":432},{"type":415,"tag":532,"props":730,"children":731},{"style":545},[732],{"type":420,"value":692},{"type":415,"tag":532,"props":734,"children":735},{"style":551},[736],{"type":420,"value":432},{"type":415,"tag":532,"props":738,"children":739},{"style":656},[740],{"type":420,"value":741},"AddAzureClients",{"type":415,"tag":532,"props":743,"children":744},{"style":551},[745],{"type":420,"value":664},{"type":415,"tag":532,"props":747,"children":748},{"style":631},[749],{"type":420,"value":750},"clientBuilder",{"type":415,"tag":532,"props":752,"children":753},{"style":551},[754],{"type":420,"value":755}," =>\n",{"type":415,"tag":532,"props":757,"children":759},{"class":534,"line":758},8,[760],{"type":415,"tag":532,"props":761,"children":762},{"style":551},[763],{"type":420,"value":764},"{\n",{"type":415,"tag":532,"props":766,"children":768},{"class":534,"line":767},9,[769,774,778,783,788,793,797,802,808,812],{"type":415,"tag":532,"props":770,"children":771},{"style":545},[772],{"type":420,"value":773},"    clientBuilder",{"type":415,"tag":532,"props":775,"children":776},{"style":551},[777],{"type":420,"value":432},{"type":415,"tag":532,"props":779,"children":780},{"style":656},[781],{"type":420,"value":782},"AddBlobServiceClient",{"type":415,"tag":532,"props":784,"children":785},{"style":551},[786],{"type":420,"value":787},"(new",{"type":415,"tag":532,"props":789,"children":790},{"style":631},[791],{"type":420,"value":792}," Uri",{"type":415,"tag":532,"props":794,"children":795},{"style":551},[796],{"type":420,"value":664},{"type":415,"tag":532,"props":798,"children":799},{"style":551},[800],{"type":420,"value":801},"\"",{"type":415,"tag":532,"props":803,"children":805},{"style":804},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[806],{"type":420,"value":807},"https://stdiwithazuresdk.blob.core.windows.net/",{"type":415,"tag":532,"props":809,"children":810},{"style":551},[811],{"type":420,"value":801},{"type":415,"tag":532,"props":813,"children":814},{"style":551},[815],{"type":420,"value":816},"));\n",{"type":415,"tag":532,"props":818,"children":820},{"class":534,"line":819},10,[821,825,829,834,838,843],{"type":415,"tag":532,"props":822,"children":823},{"style":545},[824],{"type":420,"value":773},{"type":415,"tag":532,"props":826,"children":827},{"style":551},[828],{"type":420,"value":432},{"type":415,"tag":532,"props":830,"children":831},{"style":656},[832],{"type":420,"value":833},"UseCredential",{"type":415,"tag":532,"props":835,"children":836},{"style":551},[837],{"type":420,"value":787},{"type":415,"tag":532,"props":839,"children":840},{"style":631},[841],{"type":420,"value":842}," DefaultAzureCredential",{"type":415,"tag":532,"props":844,"children":845},{"style":551},[846],{"type":420,"value":847},"());\n",{"type":415,"tag":532,"props":849,"children":851},{"class":534,"line":850},11,[852],{"type":415,"tag":532,"props":853,"children":854},{"style":551},[855],{"type":420,"value":856},"});\n",{"type":415,"tag":532,"props":858,"children":860},{"class":534,"line":859},12,[861],{"type":415,"tag":532,"props":862,"children":863},{"emptyLinePlaceholder":621},[864],{"type":420,"value":624},{"type":415,"tag":532,"props":866,"children":868},{"class":534,"line":867},13,[869,873,878,882,886,890,895],{"type":415,"tag":532,"props":870,"children":871},{"style":631},[872],{"type":420,"value":634},{"type":415,"tag":532,"props":874,"children":875},{"style":631},[876],{"type":420,"value":877}," host",{"type":415,"tag":532,"props":879,"children":880},{"style":551},[881],{"type":420,"value":644},{"type":415,"tag":532,"props":883,"children":884},{"style":545},[885],{"type":420,"value":639},{"type":415,"tag":532,"props":887,"children":888},{"style":551},[889],{"type":420,"value":432},{"type":415,"tag":532,"props":891,"children":892},{"style":656},[893],{"type":420,"value":894},"Build",{"type":415,"tag":532,"props":896,"children":897},{"style":551},[898],{"type":420,"value":899},"();\n",{"type":415,"tag":532,"props":901,"children":903},{"class":534,"line":902},14,[904,909,913,918],{"type":415,"tag":532,"props":905,"children":906},{"style":545},[907],{"type":420,"value":908},"host",{"type":415,"tag":532,"props":910,"children":911},{"style":551},[912],{"type":420,"value":432},{"type":415,"tag":532,"props":914,"children":915},{"style":656},[916],{"type":420,"value":917},"Run",{"type":415,"tag":532,"props":919,"children":920},{"style":551},[921],{"type":420,"value":899},{"type":415,"tag":416,"props":923,"children":924},{},[925,927,932,934,940],{"type":420,"value":926},"In this sample, the ",{"type":415,"tag":468,"props":928,"children":930},{"className":929},[],[931],{"type":420,"value":782},{"type":420,"value":933}," handles the registration of all dependencies for us so that the ",{"type":415,"tag":468,"props":935,"children":937},{"className":936},[],[938],{"type":420,"value":939},"BlobServiceClient",{"type":420,"value":941}," can then be injected directly where needed.",{"type":415,"tag":523,"props":943,"children":945},{"className":525,"code":944,"language":326,"meta":401,"style":401},"public class Worker : BackgroundService\n{\n    private readonly ILogger\u003CWorker> _logger;\n    private readonly BlobServiceClient _blobServiceClient;\n\n    public Worker(ILogger\u003CWorker> logger, BlobServiceClient blobServiceClient)\n    {\n        _logger = logger;\n        _blobServiceClient = blobServiceClient;\n    }\n\n    protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n    {\n        await foreach (var blobContainer in _blobServiceClient.GetBlobContainersAsync(cancellationToken: stoppingToken))\n        {\n            _logger.LogInformation(blobContainer.Name);\n        }\n    }\n}\n",[946],{"type":415,"tag":468,"props":947,"children":948},{"__ignoreMap":401},[949,978,985,1025,1050,1057,1114,1122,1143,1163,1171,1178,1224,1231,1300,1309,1354,1363,1371],{"type":415,"tag":532,"props":950,"children":951},{"class":534,"line":535},[952,958,963,968,973],{"type":415,"tag":532,"props":953,"children":955},{"style":954},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[956],{"type":420,"value":957},"public",{"type":415,"tag":532,"props":959,"children":960},{"style":631},[961],{"type":420,"value":962}," class",{"type":415,"tag":532,"props":964,"children":965},{"style":631},[966],{"type":420,"value":967}," Worker",{"type":415,"tag":532,"props":969,"children":970},{"style":551},[971],{"type":420,"value":972}," :",{"type":415,"tag":532,"props":974,"children":975},{"style":631},[976],{"type":420,"value":977}," BackgroundService\n",{"type":415,"tag":532,"props":979,"children":980},{"class":534,"line":566},[981],{"type":415,"tag":532,"props":982,"children":983},{"style":551},[984],{"type":420,"value":764},{"type":415,"tag":532,"props":986,"children":987},{"class":534,"line":583},[988,993,998,1003,1007,1011,1016,1021],{"type":415,"tag":532,"props":989,"children":990},{"style":954},[991],{"type":420,"value":992},"    private",{"type":415,"tag":532,"props":994,"children":995},{"style":954},[996],{"type":420,"value":997}," readonly",{"type":415,"tag":532,"props":999,"children":1000},{"style":631},[1001],{"type":420,"value":1002}," ILogger",{"type":415,"tag":532,"props":1004,"children":1005},{"style":551},[1006],{"type":420,"value":706},{"type":415,"tag":532,"props":1008,"children":1009},{"style":631},[1010],{"type":420,"value":711},{"type":415,"tag":532,"props":1012,"children":1013},{"style":551},[1014],{"type":420,"value":1015},">",{"type":415,"tag":532,"props":1017,"children":1018},{"style":631},[1019],{"type":420,"value":1020}," _logger",{"type":415,"tag":532,"props":1022,"children":1023},{"style":551},[1024],{"type":420,"value":563},{"type":415,"tag":532,"props":1026,"children":1027},{"class":534,"line":617},[1028,1032,1036,1041,1046],{"type":415,"tag":532,"props":1029,"children":1030},{"style":954},[1031],{"type":420,"value":992},{"type":415,"tag":532,"props":1033,"children":1034},{"style":954},[1035],{"type":420,"value":997},{"type":415,"tag":532,"props":1037,"children":1038},{"style":631},[1039],{"type":420,"value":1040}," BlobServiceClient",{"type":415,"tag":532,"props":1042,"children":1043},{"style":631},[1044],{"type":420,"value":1045}," _blobServiceClient",{"type":415,"tag":532,"props":1047,"children":1048},{"style":551},[1049],{"type":420,"value":563},{"type":415,"tag":532,"props":1051,"children":1052},{"class":534,"line":627},[1053],{"type":415,"tag":532,"props":1054,"children":1055},{"emptyLinePlaceholder":621},[1056],{"type":420,"value":624},{"type":415,"tag":532,"props":1058,"children":1059},{"class":534,"line":677},[1060,1065,1069,1073,1078,1082,1086,1090,1095,1100,1104,1109],{"type":415,"tag":532,"props":1061,"children":1062},{"style":954},[1063],{"type":420,"value":1064},"    public",{"type":415,"tag":532,"props":1066,"children":1067},{"style":656},[1068],{"type":420,"value":967},{"type":415,"tag":532,"props":1070,"children":1071},{"style":551},[1072],{"type":420,"value":664},{"type":415,"tag":532,"props":1074,"children":1075},{"style":631},[1076],{"type":420,"value":1077},"ILogger",{"type":415,"tag":532,"props":1079,"children":1080},{"style":551},[1081],{"type":420,"value":706},{"type":415,"tag":532,"props":1083,"children":1084},{"style":631},[1085],{"type":420,"value":711},{"type":415,"tag":532,"props":1087,"children":1088},{"style":551},[1089],{"type":420,"value":1015},{"type":415,"tag":532,"props":1091,"children":1092},{"style":631},[1093],{"type":420,"value":1094}," logger",{"type":415,"tag":532,"props":1096,"children":1097},{"style":551},[1098],{"type":420,"value":1099},",",{"type":415,"tag":532,"props":1101,"children":1102},{"style":631},[1103],{"type":420,"value":1040},{"type":415,"tag":532,"props":1105,"children":1106},{"style":631},[1107],{"type":420,"value":1108}," blobServiceClient",{"type":415,"tag":532,"props":1110,"children":1111},{"style":551},[1112],{"type":420,"value":1113},")\n",{"type":415,"tag":532,"props":1115,"children":1116},{"class":534,"line":719},[1117],{"type":415,"tag":532,"props":1118,"children":1119},{"style":551},[1120],{"type":420,"value":1121},"    {\n",{"type":415,"tag":532,"props":1123,"children":1124},{"class":534,"line":758},[1125,1130,1135,1139],{"type":415,"tag":532,"props":1126,"children":1127},{"style":545},[1128],{"type":420,"value":1129},"        _logger ",{"type":415,"tag":532,"props":1131,"children":1132},{"style":551},[1133],{"type":420,"value":1134},"=",{"type":415,"tag":532,"props":1136,"children":1137},{"style":545},[1138],{"type":420,"value":1094},{"type":415,"tag":532,"props":1140,"children":1141},{"style":551},[1142],{"type":420,"value":563},{"type":415,"tag":532,"props":1144,"children":1145},{"class":534,"line":767},[1146,1151,1155,1159],{"type":415,"tag":532,"props":1147,"children":1148},{"style":545},[1149],{"type":420,"value":1150},"        _blobServiceClient ",{"type":415,"tag":532,"props":1152,"children":1153},{"style":551},[1154],{"type":420,"value":1134},{"type":415,"tag":532,"props":1156,"children":1157},{"style":545},[1158],{"type":420,"value":1108},{"type":415,"tag":532,"props":1160,"children":1161},{"style":551},[1162],{"type":420,"value":563},{"type":415,"tag":532,"props":1164,"children":1165},{"class":534,"line":819},[1166],{"type":415,"tag":532,"props":1167,"children":1168},{"style":551},[1169],{"type":420,"value":1170},"    }\n",{"type":415,"tag":532,"props":1172,"children":1173},{"class":534,"line":850},[1174],{"type":415,"tag":532,"props":1175,"children":1176},{"emptyLinePlaceholder":621},[1177],{"type":420,"value":624},{"type":415,"tag":532,"props":1179,"children":1180},{"class":534,"line":859},[1181,1186,1191,1196,1201,1206,1210,1215,1220],{"type":415,"tag":532,"props":1182,"children":1183},{"style":954},[1184],{"type":420,"value":1185},"    protected",{"type":415,"tag":532,"props":1187,"children":1188},{"style":954},[1189],{"type":420,"value":1190}," override",{"type":415,"tag":532,"props":1192,"children":1193},{"style":954},[1194],{"type":420,"value":1195}," async",{"type":415,"tag":532,"props":1197,"children":1198},{"style":631},[1199],{"type":420,"value":1200}," Task",{"type":415,"tag":532,"props":1202,"children":1203},{"style":656},[1204],{"type":420,"value":1205}," ExecuteAsync",{"type":415,"tag":532,"props":1207,"children":1208},{"style":551},[1209],{"type":420,"value":664},{"type":415,"tag":532,"props":1211,"children":1212},{"style":631},[1213],{"type":420,"value":1214},"CancellationToken",{"type":415,"tag":532,"props":1216,"children":1217},{"style":631},[1218],{"type":420,"value":1219}," stoppingToken",{"type":415,"tag":532,"props":1221,"children":1222},{"style":551},[1223],{"type":420,"value":1113},{"type":415,"tag":532,"props":1225,"children":1226},{"class":534,"line":867},[1227],{"type":415,"tag":532,"props":1228,"children":1229},{"style":551},[1230],{"type":420,"value":1121},{"type":415,"tag":532,"props":1232,"children":1233},{"class":534,"line":902},[1234,1239,1245,1250,1254,1259,1264,1268,1272,1277,1281,1286,1291,1295],{"type":415,"tag":532,"props":1235,"children":1236},{"style":551},[1237],{"type":420,"value":1238},"        await",{"type":415,"tag":532,"props":1240,"children":1242},{"style":1241},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF;--shiki-light-font-style:italic;--shiki-default-font-style:italic;--shiki-dark-font-style:italic",[1243],{"type":420,"value":1244}," foreach",{"type":415,"tag":532,"props":1246,"children":1247},{"style":551},[1248],{"type":420,"value":1249}," (",{"type":415,"tag":532,"props":1251,"children":1252},{"style":631},[1253],{"type":420,"value":634},{"type":415,"tag":532,"props":1255,"children":1256},{"style":631},[1257],{"type":420,"value":1258}," blobContainer",{"type":415,"tag":532,"props":1260,"children":1261},{"style":1241},[1262],{"type":420,"value":1263}," in",{"type":415,"tag":532,"props":1265,"children":1266},{"style":545},[1267],{"type":420,"value":1045},{"type":415,"tag":532,"props":1269,"children":1270},{"style":551},[1271],{"type":420,"value":432},{"type":415,"tag":532,"props":1273,"children":1274},{"style":656},[1275],{"type":420,"value":1276},"GetBlobContainersAsync",{"type":415,"tag":532,"props":1278,"children":1279},{"style":551},[1280],{"type":420,"value":664},{"type":415,"tag":532,"props":1282,"children":1283},{"style":631},[1284],{"type":420,"value":1285},"cancellationToken",{"type":415,"tag":532,"props":1287,"children":1288},{"style":551},[1289],{"type":420,"value":1290},":",{"type":415,"tag":532,"props":1292,"children":1293},{"style":545},[1294],{"type":420,"value":1219},{"type":415,"tag":532,"props":1296,"children":1297},{"style":551},[1298],{"type":420,"value":1299},"))\n",{"type":415,"tag":532,"props":1301,"children":1303},{"class":534,"line":1302},15,[1304],{"type":415,"tag":532,"props":1305,"children":1306},{"style":551},[1307],{"type":420,"value":1308},"        {\n",{"type":415,"tag":532,"props":1310,"children":1312},{"class":534,"line":1311},16,[1313,1318,1322,1327,1331,1336,1340,1345,1350],{"type":415,"tag":532,"props":1314,"children":1315},{"style":545},[1316],{"type":420,"value":1317},"            _logger",{"type":415,"tag":532,"props":1319,"children":1320},{"style":551},[1321],{"type":420,"value":432},{"type":415,"tag":532,"props":1323,"children":1324},{"style":656},[1325],{"type":420,"value":1326},"LogInformation",{"type":415,"tag":532,"props":1328,"children":1329},{"style":551},[1330],{"type":420,"value":664},{"type":415,"tag":532,"props":1332,"children":1333},{"style":545},[1334],{"type":420,"value":1335},"blobContainer",{"type":415,"tag":532,"props":1337,"children":1338},{"style":551},[1339],{"type":420,"value":432},{"type":415,"tag":532,"props":1341,"children":1342},{"style":545},[1343],{"type":420,"value":1344},"Name",{"type":415,"tag":532,"props":1346,"children":1347},{"style":551},[1348],{"type":420,"value":1349},")",{"type":415,"tag":532,"props":1351,"children":1352},{"style":545},[1353],{"type":420,"value":563},{"type":415,"tag":532,"props":1355,"children":1357},{"class":534,"line":1356},17,[1358],{"type":415,"tag":532,"props":1359,"children":1360},{"style":551},[1361],{"type":420,"value":1362},"        }\n",{"type":415,"tag":532,"props":1364,"children":1366},{"class":534,"line":1365},18,[1367],{"type":415,"tag":532,"props":1368,"children":1369},{"style":551},[1370],{"type":420,"value":1170},{"type":415,"tag":532,"props":1372,"children":1374},{"class":534,"line":1373},19,[1375],{"type":415,"tag":532,"props":1376,"children":1377},{"style":551},[1378],{"type":420,"value":1379},"}\n",{"type":415,"tag":434,"props":1381,"children":1383},{"icon":1382},"i-heroicons-chat-bubble-left-20-solid",[1384],{"type":415,"tag":416,"props":1385,"children":1386},{},[1387,1389,1394,1396,1402,1404,1410,1412,1417],{"type":420,"value":1388},"You may find it convenient to configure the dependency injection for all Azure service clients in a central place with the ",{"type":415,"tag":468,"props":1390,"children":1392},{"className":1391},[],[1393],{"type":420,"value":741},{"type":420,"value":1395}," method. When applications become larger with different ",{"type":415,"tag":468,"props":1397,"children":1399},{"className":1398},[],[1400],{"type":420,"value":1401},"csproj,",{"type":420,"value":1403}," I often prefer to separate service registration by business domain/module so having everything in a central place does not always suit my needs. That's not a problem, as the internal methods of the library make use of the ",{"type":415,"tag":468,"props":1405,"children":1407},{"className":1406},[],[1408],{"type":420,"value":1409},"TryAddd",{"type":420,"value":1411}," methods for registering services, I can call ",{"type":415,"tag":468,"props":1413,"children":1415},{"className":1414},[],[1416],{"type":420,"value":741},{"type":420,"value":1418}," in multiple places with only the services I want to register.",{"type":415,"tag":482,"props":1420,"children":1422},{"id":1421},"easily-manage-the-authentication-to-azure-services",[1423],{"type":420,"value":1424},"Easily manage the authentication to Azure services",{"type":415,"tag":416,"props":1426,"children":1427},{},[1428,1430,1437],{"type":420,"value":1429},"All the SDKs use the ",{"type":415,"tag":423,"props":1431,"children":1434},{"href":1432,"rel":1433},"https://www.nuget.org/packages/Azure.Identity",[427],[1435],{"type":420,"value":1436},"Azure.Identity",{"type":420,"value":1438}," package to authenticate to Azure. There are different authentication methods available and you can easily specify which one to use with each client. Additionally, you can define a default authentication method for all clients, as demonstrated in the previous example.",{"type":415,"tag":523,"props":1440,"children":1442},{"className":525,"code":1441,"language":326,"meta":401,"style":401},"builder.Services.AddAzureClients(clientBuilder =>\n{\n    clientBuilder.AddServiceBusClient(\"https://sb-diwithazuresdk.servicebus.windows.net/\")\n        .WithCredential(new ManagedIdentityCredential());\n    \n    clientBuilder.AddTableServiceClient(new Uri(\"https://stdiwithazuresdk.table.core.windows.net\"))\n        .WithCredential(new EnvironmentCredential());\n\n    clientBuilder.AddBlobServiceClient(new Uri(\"https://stdiwithazuresdk.blob.core.windows.net/\"));\n    \n    clientBuilder.UseCredential(new DefaultAzureCredential());\n});\n",[1443],{"type":415,"tag":468,"props":1444,"children":1445},{"__ignoreMap":401},[1446,1481,1488,1525,1551,1559,1604,1628,1635,1678,1685,1712],{"type":415,"tag":532,"props":1447,"children":1448},{"class":534,"line":535},[1449,1453,1457,1461,1465,1469,1473,1477],{"type":415,"tag":532,"props":1450,"children":1451},{"style":545},[1452],{"type":420,"value":683},{"type":415,"tag":532,"props":1454,"children":1455},{"style":551},[1456],{"type":420,"value":432},{"type":415,"tag":532,"props":1458,"children":1459},{"style":545},[1460],{"type":420,"value":692},{"type":415,"tag":532,"props":1462,"children":1463},{"style":551},[1464],{"type":420,"value":432},{"type":415,"tag":532,"props":1466,"children":1467},{"style":656},[1468],{"type":420,"value":741},{"type":415,"tag":532,"props":1470,"children":1471},{"style":551},[1472],{"type":420,"value":664},{"type":415,"tag":532,"props":1474,"children":1475},{"style":631},[1476],{"type":420,"value":750},{"type":415,"tag":532,"props":1478,"children":1479},{"style":551},[1480],{"type":420,"value":755},{"type":415,"tag":532,"props":1482,"children":1483},{"class":534,"line":566},[1484],{"type":415,"tag":532,"props":1485,"children":1486},{"style":551},[1487],{"type":420,"value":764},{"type":415,"tag":532,"props":1489,"children":1490},{"class":534,"line":583},[1491,1495,1499,1504,1508,1512,1517,1521],{"type":415,"tag":532,"props":1492,"children":1493},{"style":545},[1494],{"type":420,"value":773},{"type":415,"tag":532,"props":1496,"children":1497},{"style":551},[1498],{"type":420,"value":432},{"type":415,"tag":532,"props":1500,"children":1501},{"style":656},[1502],{"type":420,"value":1503},"AddServiceBusClient",{"type":415,"tag":532,"props":1505,"children":1506},{"style":551},[1507],{"type":420,"value":664},{"type":415,"tag":532,"props":1509,"children":1510},{"style":551},[1511],{"type":420,"value":801},{"type":415,"tag":532,"props":1513,"children":1514},{"style":804},[1515],{"type":420,"value":1516},"https://sb-diwithazuresdk.servicebus.windows.net/",{"type":415,"tag":532,"props":1518,"children":1519},{"style":551},[1520],{"type":420,"value":801},{"type":415,"tag":532,"props":1522,"children":1523},{"style":551},[1524],{"type":420,"value":1113},{"type":415,"tag":532,"props":1526,"children":1527},{"class":534,"line":617},[1528,1533,1538,1542,1547],{"type":415,"tag":532,"props":1529,"children":1530},{"style":551},[1531],{"type":420,"value":1532},"        .",{"type":415,"tag":532,"props":1534,"children":1535},{"style":656},[1536],{"type":420,"value":1537},"WithCredential",{"type":415,"tag":532,"props":1539,"children":1540},{"style":551},[1541],{"type":420,"value":787},{"type":415,"tag":532,"props":1543,"children":1544},{"style":631},[1545],{"type":420,"value":1546}," ManagedIdentityCredential",{"type":415,"tag":532,"props":1548,"children":1549},{"style":551},[1550],{"type":420,"value":847},{"type":415,"tag":532,"props":1552,"children":1553},{"class":534,"line":627},[1554],{"type":415,"tag":532,"props":1555,"children":1556},{"style":545},[1557],{"type":420,"value":1558},"    \n",{"type":415,"tag":532,"props":1560,"children":1561},{"class":534,"line":677},[1562,1566,1570,1575,1579,1583,1587,1591,1596,1600],{"type":415,"tag":532,"props":1563,"children":1564},{"style":545},[1565],{"type":420,"value":773},{"type":415,"tag":532,"props":1567,"children":1568},{"style":551},[1569],{"type":420,"value":432},{"type":415,"tag":532,"props":1571,"children":1572},{"style":656},[1573],{"type":420,"value":1574},"AddTableServiceClient",{"type":415,"tag":532,"props":1576,"children":1577},{"style":551},[1578],{"type":420,"value":787},{"type":415,"tag":532,"props":1580,"children":1581},{"style":631},[1582],{"type":420,"value":792},{"type":415,"tag":532,"props":1584,"children":1585},{"style":551},[1586],{"type":420,"value":664},{"type":415,"tag":532,"props":1588,"children":1589},{"style":551},[1590],{"type":420,"value":801},{"type":415,"tag":532,"props":1592,"children":1593},{"style":804},[1594],{"type":420,"value":1595},"https://stdiwithazuresdk.table.core.windows.net",{"type":415,"tag":532,"props":1597,"children":1598},{"style":551},[1599],{"type":420,"value":801},{"type":415,"tag":532,"props":1601,"children":1602},{"style":551},[1603],{"type":420,"value":1299},{"type":415,"tag":532,"props":1605,"children":1606},{"class":534,"line":719},[1607,1611,1615,1619,1624],{"type":415,"tag":532,"props":1608,"children":1609},{"style":551},[1610],{"type":420,"value":1532},{"type":415,"tag":532,"props":1612,"children":1613},{"style":656},[1614],{"type":420,"value":1537},{"type":415,"tag":532,"props":1616,"children":1617},{"style":551},[1618],{"type":420,"value":787},{"type":415,"tag":532,"props":1620,"children":1621},{"style":631},[1622],{"type":420,"value":1623}," EnvironmentCredential",{"type":415,"tag":532,"props":1625,"children":1626},{"style":551},[1627],{"type":420,"value":847},{"type":415,"tag":532,"props":1629,"children":1630},{"class":534,"line":758},[1631],{"type":415,"tag":532,"props":1632,"children":1633},{"emptyLinePlaceholder":621},[1634],{"type":420,"value":624},{"type":415,"tag":532,"props":1636,"children":1637},{"class":534,"line":767},[1638,1642,1646,1650,1654,1658,1662,1666,1670,1674],{"type":415,"tag":532,"props":1639,"children":1640},{"style":545},[1641],{"type":420,"value":773},{"type":415,"tag":532,"props":1643,"children":1644},{"style":551},[1645],{"type":420,"value":432},{"type":415,"tag":532,"props":1647,"children":1648},{"style":656},[1649],{"type":420,"value":782},{"type":415,"tag":532,"props":1651,"children":1652},{"style":551},[1653],{"type":420,"value":787},{"type":415,"tag":532,"props":1655,"children":1656},{"style":631},[1657],{"type":420,"value":792},{"type":415,"tag":532,"props":1659,"children":1660},{"style":551},[1661],{"type":420,"value":664},{"type":415,"tag":532,"props":1663,"children":1664},{"style":551},[1665],{"type":420,"value":801},{"type":415,"tag":532,"props":1667,"children":1668},{"style":804},[1669],{"type":420,"value":807},{"type":415,"tag":532,"props":1671,"children":1672},{"style":551},[1673],{"type":420,"value":801},{"type":415,"tag":532,"props":1675,"children":1676},{"style":551},[1677],{"type":420,"value":816},{"type":415,"tag":532,"props":1679,"children":1680},{"class":534,"line":819},[1681],{"type":415,"tag":532,"props":1682,"children":1683},{"style":545},[1684],{"type":420,"value":1558},{"type":415,"tag":532,"props":1686,"children":1687},{"class":534,"line":850},[1688,1692,1696,1700,1704,1708],{"type":415,"tag":532,"props":1689,"children":1690},{"style":545},[1691],{"type":420,"value":773},{"type":415,"tag":532,"props":1693,"children":1694},{"style":551},[1695],{"type":420,"value":432},{"type":415,"tag":532,"props":1697,"children":1698},{"style":656},[1699],{"type":420,"value":833},{"type":415,"tag":532,"props":1701,"children":1702},{"style":551},[1703],{"type":420,"value":787},{"type":415,"tag":532,"props":1705,"children":1706},{"style":631},[1707],{"type":420,"value":842},{"type":415,"tag":532,"props":1709,"children":1710},{"style":551},[1711],{"type":420,"value":847},{"type":415,"tag":532,"props":1713,"children":1714},{"class":534,"line":859},[1715],{"type":415,"tag":532,"props":1716,"children":1717},{"style":551},[1718],{"type":420,"value":856},{"type":415,"tag":416,"props":1720,"children":1721},{},[1722],{"type":420,"value":1723},"In the example above, we configured:",{"type":415,"tag":508,"props":1725,"children":1726},{},[1727,1732,1737],{"type":415,"tag":512,"props":1728,"children":1729},{},[1730],{"type":420,"value":1731},"the service bus client to use the managed identity of the application to obtain a valid token for the service bus",{"type":415,"tag":512,"props":1733,"children":1734},{},[1735],{"type":420,"value":1736},"the table client to use environment variables to obtain a valid token for the storage table",{"type":415,"tag":512,"props":1738,"children":1739},{},[1740,1742,1747],{"type":420,"value":1741},"the blob client without any credentials so that it will use the one that we configured by default (with the ",{"type":415,"tag":468,"props":1743,"children":1745},{"className":1744},[],[1746],{"type":420,"value":833},{"type":420,"value":1748}," method)",{"type":415,"tag":482,"props":1750,"children":1752},{"id":1751},"effortlessly-configure-the-azure-clients-options",[1753],{"type":420,"value":1754},"Effortlessly configure the Azure clients' options",{"type":415,"tag":416,"props":1756,"children":1757},{},[1758,1760,1765],{"type":420,"value":1759},"All Azure clients have options that can be effortlessly configured when registering them in the ",{"type":415,"tag":468,"props":1761,"children":1763},{"className":1762},[],[1764],{"type":420,"value":741},{"type":420,"value":1766}," method.",{"type":415,"tag":523,"props":1768,"children":1770},{"className":525,"code":1769,"language":326,"meta":401,"style":401},"builder.Services.AddAzureClients(clientBuilder =>\n{\n    clientBuilder.AddBlobServiceClient(new Uri(\"https://stdiwithazuresdk.blob.core.windows.net/\"))\n        .WithCredential(new DefaultAzureCredential())\n        .ConfigureOptions(options =>\n        {\n            options.TrimBlobNameSlashes = true;\n            options.Retry.MaxRetries = 10;\n            options.Diagnostics.IsLoggingEnabled = false;\n        });\n});\n",[1771],{"type":415,"tag":468,"props":1772,"children":1773},{"__ignoreMap":401},[1774,1809,1816,1859,1883,1908,1915,1946,1984,2022,2030],{"type":415,"tag":532,"props":1775,"children":1776},{"class":534,"line":535},[1777,1781,1785,1789,1793,1797,1801,1805],{"type":415,"tag":532,"props":1778,"children":1779},{"style":545},[1780],{"type":420,"value":683},{"type":415,"tag":532,"props":1782,"children":1783},{"style":551},[1784],{"type":420,"value":432},{"type":415,"tag":532,"props":1786,"children":1787},{"style":545},[1788],{"type":420,"value":692},{"type":415,"tag":532,"props":1790,"children":1791},{"style":551},[1792],{"type":420,"value":432},{"type":415,"tag":532,"props":1794,"children":1795},{"style":656},[1796],{"type":420,"value":741},{"type":415,"tag":532,"props":1798,"children":1799},{"style":551},[1800],{"type":420,"value":664},{"type":415,"tag":532,"props":1802,"children":1803},{"style":631},[1804],{"type":420,"value":750},{"type":415,"tag":532,"props":1806,"children":1807},{"style":551},[1808],{"type":420,"value":755},{"type":415,"tag":532,"props":1810,"children":1811},{"class":534,"line":566},[1812],{"type":415,"tag":532,"props":1813,"children":1814},{"style":551},[1815],{"type":420,"value":764},{"type":415,"tag":532,"props":1817,"children":1818},{"class":534,"line":583},[1819,1823,1827,1831,1835,1839,1843,1847,1851,1855],{"type":415,"tag":532,"props":1820,"children":1821},{"style":545},[1822],{"type":420,"value":773},{"type":415,"tag":532,"props":1824,"children":1825},{"style":551},[1826],{"type":420,"value":432},{"type":415,"tag":532,"props":1828,"children":1829},{"style":656},[1830],{"type":420,"value":782},{"type":415,"tag":532,"props":1832,"children":1833},{"style":551},[1834],{"type":420,"value":787},{"type":415,"tag":532,"props":1836,"children":1837},{"style":631},[1838],{"type":420,"value":792},{"type":415,"tag":532,"props":1840,"children":1841},{"style":551},[1842],{"type":420,"value":664},{"type":415,"tag":532,"props":1844,"children":1845},{"style":551},[1846],{"type":420,"value":801},{"type":415,"tag":532,"props":1848,"children":1849},{"style":804},[1850],{"type":420,"value":807},{"type":415,"tag":532,"props":1852,"children":1853},{"style":551},[1854],{"type":420,"value":801},{"type":415,"tag":532,"props":1856,"children":1857},{"style":551},[1858],{"type":420,"value":1299},{"type":415,"tag":532,"props":1860,"children":1861},{"class":534,"line":617},[1862,1866,1870,1874,1878],{"type":415,"tag":532,"props":1863,"children":1864},{"style":551},[1865],{"type":420,"value":1532},{"type":415,"tag":532,"props":1867,"children":1868},{"style":656},[1869],{"type":420,"value":1537},{"type":415,"tag":532,"props":1871,"children":1872},{"style":551},[1873],{"type":420,"value":787},{"type":415,"tag":532,"props":1875,"children":1876},{"style":631},[1877],{"type":420,"value":842},{"type":415,"tag":532,"props":1879,"children":1880},{"style":551},[1881],{"type":420,"value":1882},"())\n",{"type":415,"tag":532,"props":1884,"children":1885},{"class":534,"line":627},[1886,1890,1895,1899,1904],{"type":415,"tag":532,"props":1887,"children":1888},{"style":551},[1889],{"type":420,"value":1532},{"type":415,"tag":532,"props":1891,"children":1892},{"style":656},[1893],{"type":420,"value":1894},"ConfigureOptions",{"type":415,"tag":532,"props":1896,"children":1897},{"style":551},[1898],{"type":420,"value":664},{"type":415,"tag":532,"props":1900,"children":1901},{"style":631},[1902],{"type":420,"value":1903},"options",{"type":415,"tag":532,"props":1905,"children":1906},{"style":551},[1907],{"type":420,"value":755},{"type":415,"tag":532,"props":1909,"children":1910},{"class":534,"line":677},[1911],{"type":415,"tag":532,"props":1912,"children":1913},{"style":551},[1914],{"type":420,"value":1308},{"type":415,"tag":532,"props":1916,"children":1917},{"class":534,"line":719},[1918,1923,1927,1932,1936,1942],{"type":415,"tag":532,"props":1919,"children":1920},{"style":545},[1921],{"type":420,"value":1922},"            options",{"type":415,"tag":532,"props":1924,"children":1925},{"style":551},[1926],{"type":420,"value":432},{"type":415,"tag":532,"props":1928,"children":1929},{"style":545},[1930],{"type":420,"value":1931},"TrimBlobNameSlashes ",{"type":415,"tag":532,"props":1933,"children":1934},{"style":551},[1935],{"type":420,"value":1134},{"type":415,"tag":532,"props":1937,"children":1939},{"style":1938},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[1940],{"type":420,"value":1941}," true",{"type":415,"tag":532,"props":1943,"children":1944},{"style":551},[1945],{"type":420,"value":563},{"type":415,"tag":532,"props":1947,"children":1948},{"class":534,"line":758},[1949,1953,1957,1962,1966,1971,1975,1980],{"type":415,"tag":532,"props":1950,"children":1951},{"style":545},[1952],{"type":420,"value":1922},{"type":415,"tag":532,"props":1954,"children":1955},{"style":551},[1956],{"type":420,"value":432},{"type":415,"tag":532,"props":1958,"children":1959},{"style":545},[1960],{"type":420,"value":1961},"Retry",{"type":415,"tag":532,"props":1963,"children":1964},{"style":551},[1965],{"type":420,"value":432},{"type":415,"tag":532,"props":1967,"children":1968},{"style":545},[1969],{"type":420,"value":1970},"MaxRetries ",{"type":415,"tag":532,"props":1972,"children":1973},{"style":551},[1974],{"type":420,"value":1134},{"type":415,"tag":532,"props":1976,"children":1977},{"style":539},[1978],{"type":420,"value":1979}," 10",{"type":415,"tag":532,"props":1981,"children":1982},{"style":551},[1983],{"type":420,"value":563},{"type":415,"tag":532,"props":1985,"children":1986},{"class":534,"line":767},[1987,1991,1995,2000,2004,2009,2013,2018],{"type":415,"tag":532,"props":1988,"children":1989},{"style":545},[1990],{"type":420,"value":1922},{"type":415,"tag":532,"props":1992,"children":1993},{"style":551},[1994],{"type":420,"value":432},{"type":415,"tag":532,"props":1996,"children":1997},{"style":545},[1998],{"type":420,"value":1999},"Diagnostics",{"type":415,"tag":532,"props":2001,"children":2002},{"style":551},[2003],{"type":420,"value":432},{"type":415,"tag":532,"props":2005,"children":2006},{"style":545},[2007],{"type":420,"value":2008},"IsLoggingEnabled ",{"type":415,"tag":532,"props":2010,"children":2011},{"style":551},[2012],{"type":420,"value":1134},{"type":415,"tag":532,"props":2014,"children":2015},{"style":1938},[2016],{"type":420,"value":2017}," false",{"type":415,"tag":532,"props":2019,"children":2020},{"style":551},[2021],{"type":420,"value":563},{"type":415,"tag":532,"props":2023,"children":2024},{"class":534,"line":819},[2025],{"type":415,"tag":532,"props":2026,"children":2027},{"style":551},[2028],{"type":420,"value":2029},"        });\n",{"type":415,"tag":532,"props":2031,"children":2032},{"class":534,"line":850},[2033],{"type":415,"tag":532,"props":2034,"children":2035},{"style":551},[2036],{"type":420,"value":856},{"type":415,"tag":416,"props":2038,"children":2039},{},[2040,2042,2048],{"type":420,"value":2041},"Some options are specific to the client (like the ",{"type":415,"tag":468,"props":2043,"children":2045},{"className":2044},[],[2046],{"type":420,"value":2047},"TrimBlobNameSlashes",{"type":420,"value":2049}," here for Blob client). Others can be configured globally and overridden on a client if necessary.",{"type":415,"tag":523,"props":2051,"children":2053},{"className":525,"code":2052,"language":326,"meta":401,"style":401},"builder.Services.AddAzureClients(clientBuilder =>\n{\n   clientBuilder.AddBlobServiceClient(new Uri(\"https://stdiwithazuresdk.blob.core.windows.net/\"))\n        .WithCredential(new DefaultAzureCredential())\n        .ConfigureOptions(options =>\n        {\n            options.TrimBlobNameSlashes = true;\n            options.Retry.MaxRetries = 10;\n            options.Diagnostics.IsLoggingEnabled = false;\n        });\n    \n    clientBuilder.ConfigureDefaults(options =>\n    {\n        options.Retry.MaxRetries = 5;\n        options.Retry.Mode = RetryMode.Exponential;\n        options.Diagnostics.IsDistributedTracingEnabled = true;\n    });\n});\n",[2054],{"type":415,"tag":468,"props":2055,"children":2056},{"__ignoreMap":401},[2057,2092,2099,2143,2166,2189,2196,2223,2258,2293,2300,2307,2335,2342,2379,2425,2461,2469],{"type":415,"tag":532,"props":2058,"children":2059},{"class":534,"line":535},[2060,2064,2068,2072,2076,2080,2084,2088],{"type":415,"tag":532,"props":2061,"children":2062},{"style":545},[2063],{"type":420,"value":683},{"type":415,"tag":532,"props":2065,"children":2066},{"style":551},[2067],{"type":420,"value":432},{"type":415,"tag":532,"props":2069,"children":2070},{"style":545},[2071],{"type":420,"value":692},{"type":415,"tag":532,"props":2073,"children":2074},{"style":551},[2075],{"type":420,"value":432},{"type":415,"tag":532,"props":2077,"children":2078},{"style":656},[2079],{"type":420,"value":741},{"type":415,"tag":532,"props":2081,"children":2082},{"style":551},[2083],{"type":420,"value":664},{"type":415,"tag":532,"props":2085,"children":2086},{"style":631},[2087],{"type":420,"value":750},{"type":415,"tag":532,"props":2089,"children":2090},{"style":551},[2091],{"type":420,"value":755},{"type":415,"tag":532,"props":2093,"children":2094},{"class":534,"line":566},[2095],{"type":415,"tag":532,"props":2096,"children":2097},{"style":551},[2098],{"type":420,"value":764},{"type":415,"tag":532,"props":2100,"children":2101},{"class":534,"line":583},[2102,2107,2111,2115,2119,2123,2127,2131,2135,2139],{"type":415,"tag":532,"props":2103,"children":2104},{"style":545},[2105],{"type":420,"value":2106},"   clientBuilder",{"type":415,"tag":532,"props":2108,"children":2109},{"style":551},[2110],{"type":420,"value":432},{"type":415,"tag":532,"props":2112,"children":2113},{"style":656},[2114],{"type":420,"value":782},{"type":415,"tag":532,"props":2116,"children":2117},{"style":551},[2118],{"type":420,"value":787},{"type":415,"tag":532,"props":2120,"children":2121},{"style":631},[2122],{"type":420,"value":792},{"type":415,"tag":532,"props":2124,"children":2125},{"style":551},[2126],{"type":420,"value":664},{"type":415,"tag":532,"props":2128,"children":2129},{"style":551},[2130],{"type":420,"value":801},{"type":415,"tag":532,"props":2132,"children":2133},{"style":804},[2134],{"type":420,"value":807},{"type":415,"tag":532,"props":2136,"children":2137},{"style":551},[2138],{"type":420,"value":801},{"type":415,"tag":532,"props":2140,"children":2141},{"style":551},[2142],{"type":420,"value":1299},{"type":415,"tag":532,"props":2144,"children":2145},{"class":534,"line":617},[2146,2150,2154,2158,2162],{"type":415,"tag":532,"props":2147,"children":2148},{"style":551},[2149],{"type":420,"value":1532},{"type":415,"tag":532,"props":2151,"children":2152},{"style":656},[2153],{"type":420,"value":1537},{"type":415,"tag":532,"props":2155,"children":2156},{"style":551},[2157],{"type":420,"value":787},{"type":415,"tag":532,"props":2159,"children":2160},{"style":631},[2161],{"type":420,"value":842},{"type":415,"tag":532,"props":2163,"children":2164},{"style":551},[2165],{"type":420,"value":1882},{"type":415,"tag":532,"props":2167,"children":2168},{"class":534,"line":627},[2169,2173,2177,2181,2185],{"type":415,"tag":532,"props":2170,"children":2171},{"style":551},[2172],{"type":420,"value":1532},{"type":415,"tag":532,"props":2174,"children":2175},{"style":656},[2176],{"type":420,"value":1894},{"type":415,"tag":532,"props":2178,"children":2179},{"style":551},[2180],{"type":420,"value":664},{"type":415,"tag":532,"props":2182,"children":2183},{"style":631},[2184],{"type":420,"value":1903},{"type":415,"tag":532,"props":2186,"children":2187},{"style":551},[2188],{"type":420,"value":755},{"type":415,"tag":532,"props":2190,"children":2191},{"class":534,"line":677},[2192],{"type":415,"tag":532,"props":2193,"children":2194},{"style":551},[2195],{"type":420,"value":1308},{"type":415,"tag":532,"props":2197,"children":2198},{"class":534,"line":719},[2199,2203,2207,2211,2215,2219],{"type":415,"tag":532,"props":2200,"children":2201},{"style":545},[2202],{"type":420,"value":1922},{"type":415,"tag":532,"props":2204,"children":2205},{"style":551},[2206],{"type":420,"value":432},{"type":415,"tag":532,"props":2208,"children":2209},{"style":545},[2210],{"type":420,"value":1931},{"type":415,"tag":532,"props":2212,"children":2213},{"style":551},[2214],{"type":420,"value":1134},{"type":415,"tag":532,"props":2216,"children":2217},{"style":1938},[2218],{"type":420,"value":1941},{"type":415,"tag":532,"props":2220,"children":2221},{"style":551},[2222],{"type":420,"value":563},{"type":415,"tag":532,"props":2224,"children":2225},{"class":534,"line":758},[2226,2230,2234,2238,2242,2246,2250,2254],{"type":415,"tag":532,"props":2227,"children":2228},{"style":545},[2229],{"type":420,"value":1922},{"type":415,"tag":532,"props":2231,"children":2232},{"style":551},[2233],{"type":420,"value":432},{"type":415,"tag":532,"props":2235,"children":2236},{"style":545},[2237],{"type":420,"value":1961},{"type":415,"tag":532,"props":2239,"children":2240},{"style":551},[2241],{"type":420,"value":432},{"type":415,"tag":532,"props":2243,"children":2244},{"style":545},[2245],{"type":420,"value":1970},{"type":415,"tag":532,"props":2247,"children":2248},{"style":551},[2249],{"type":420,"value":1134},{"type":415,"tag":532,"props":2251,"children":2252},{"style":539},[2253],{"type":420,"value":1979},{"type":415,"tag":532,"props":2255,"children":2256},{"style":551},[2257],{"type":420,"value":563},{"type":415,"tag":532,"props":2259,"children":2260},{"class":534,"line":767},[2261,2265,2269,2273,2277,2281,2285,2289],{"type":415,"tag":532,"props":2262,"children":2263},{"style":545},[2264],{"type":420,"value":1922},{"type":415,"tag":532,"props":2266,"children":2267},{"style":551},[2268],{"type":420,"value":432},{"type":415,"tag":532,"props":2270,"children":2271},{"style":545},[2272],{"type":420,"value":1999},{"type":415,"tag":532,"props":2274,"children":2275},{"style":551},[2276],{"type":420,"value":432},{"type":415,"tag":532,"props":2278,"children":2279},{"style":545},[2280],{"type":420,"value":2008},{"type":415,"tag":532,"props":2282,"children":2283},{"style":551},[2284],{"type":420,"value":1134},{"type":415,"tag":532,"props":2286,"children":2287},{"style":1938},[2288],{"type":420,"value":2017},{"type":415,"tag":532,"props":2290,"children":2291},{"style":551},[2292],{"type":420,"value":563},{"type":415,"tag":532,"props":2294,"children":2295},{"class":534,"line":819},[2296],{"type":415,"tag":532,"props":2297,"children":2298},{"style":551},[2299],{"type":420,"value":2029},{"type":415,"tag":532,"props":2301,"children":2302},{"class":534,"line":850},[2303],{"type":415,"tag":532,"props":2304,"children":2305},{"style":545},[2306],{"type":420,"value":1558},{"type":415,"tag":532,"props":2308,"children":2309},{"class":534,"line":859},[2310,2314,2318,2323,2327,2331],{"type":415,"tag":532,"props":2311,"children":2312},{"style":545},[2313],{"type":420,"value":773},{"type":415,"tag":532,"props":2315,"children":2316},{"style":551},[2317],{"type":420,"value":432},{"type":415,"tag":532,"props":2319,"children":2320},{"style":656},[2321],{"type":420,"value":2322},"ConfigureDefaults",{"type":415,"tag":532,"props":2324,"children":2325},{"style":551},[2326],{"type":420,"value":664},{"type":415,"tag":532,"props":2328,"children":2329},{"style":631},[2330],{"type":420,"value":1903},{"type":415,"tag":532,"props":2332,"children":2333},{"style":551},[2334],{"type":420,"value":755},{"type":415,"tag":532,"props":2336,"children":2337},{"class":534,"line":867},[2338],{"type":415,"tag":532,"props":2339,"children":2340},{"style":551},[2341],{"type":420,"value":1121},{"type":415,"tag":532,"props":2343,"children":2344},{"class":534,"line":902},[2345,2350,2354,2358,2362,2366,2370,2375],{"type":415,"tag":532,"props":2346,"children":2347},{"style":545},[2348],{"type":420,"value":2349},"        options",{"type":415,"tag":532,"props":2351,"children":2352},{"style":551},[2353],{"type":420,"value":432},{"type":415,"tag":532,"props":2355,"children":2356},{"style":545},[2357],{"type":420,"value":1961},{"type":415,"tag":532,"props":2359,"children":2360},{"style":551},[2361],{"type":420,"value":432},{"type":415,"tag":532,"props":2363,"children":2364},{"style":545},[2365],{"type":420,"value":1970},{"type":415,"tag":532,"props":2367,"children":2368},{"style":551},[2369],{"type":420,"value":1134},{"type":415,"tag":532,"props":2371,"children":2372},{"style":539},[2373],{"type":420,"value":2374}," 5",{"type":415,"tag":532,"props":2376,"children":2377},{"style":551},[2378],{"type":420,"value":563},{"type":415,"tag":532,"props":2380,"children":2381},{"class":534,"line":1302},[2382,2386,2390,2394,2398,2403,2407,2412,2416,2421],{"type":415,"tag":532,"props":2383,"children":2384},{"style":545},[2385],{"type":420,"value":2349},{"type":415,"tag":532,"props":2387,"children":2388},{"style":551},[2389],{"type":420,"value":432},{"type":415,"tag":532,"props":2391,"children":2392},{"style":545},[2393],{"type":420,"value":1961},{"type":415,"tag":532,"props":2395,"children":2396},{"style":551},[2397],{"type":420,"value":432},{"type":415,"tag":532,"props":2399,"children":2400},{"style":545},[2401],{"type":420,"value":2402},"Mode ",{"type":415,"tag":532,"props":2404,"children":2405},{"style":551},[2406],{"type":420,"value":1134},{"type":415,"tag":532,"props":2408,"children":2409},{"style":545},[2410],{"type":420,"value":2411}," RetryMode",{"type":415,"tag":532,"props":2413,"children":2414},{"style":551},[2415],{"type":420,"value":432},{"type":415,"tag":532,"props":2417,"children":2418},{"style":545},[2419],{"type":420,"value":2420},"Exponential",{"type":415,"tag":532,"props":2422,"children":2423},{"style":551},[2424],{"type":420,"value":563},{"type":415,"tag":532,"props":2426,"children":2427},{"class":534,"line":1311},[2428,2432,2436,2440,2444,2449,2453,2457],{"type":415,"tag":532,"props":2429,"children":2430},{"style":545},[2431],{"type":420,"value":2349},{"type":415,"tag":532,"props":2433,"children":2434},{"style":551},[2435],{"type":420,"value":432},{"type":415,"tag":532,"props":2437,"children":2438},{"style":545},[2439],{"type":420,"value":1999},{"type":415,"tag":532,"props":2441,"children":2442},{"style":551},[2443],{"type":420,"value":432},{"type":415,"tag":532,"props":2445,"children":2446},{"style":545},[2447],{"type":420,"value":2448},"IsDistributedTracingEnabled ",{"type":415,"tag":532,"props":2450,"children":2451},{"style":551},[2452],{"type":420,"value":1134},{"type":415,"tag":532,"props":2454,"children":2455},{"style":1938},[2456],{"type":420,"value":1941},{"type":415,"tag":532,"props":2458,"children":2459},{"style":551},[2460],{"type":420,"value":563},{"type":415,"tag":532,"props":2462,"children":2463},{"class":534,"line":1356},[2464],{"type":415,"tag":532,"props":2465,"children":2466},{"style":551},[2467],{"type":420,"value":2468},"    });\n",{"type":415,"tag":532,"props":2470,"children":2471},{"class":534,"line":1365},[2472],{"type":415,"tag":532,"props":2473,"children":2474},{"style":551},[2475],{"type":420,"value":856},{"type":415,"tag":416,"props":2477,"children":2478},{},[2479,2481,2486],{"type":420,"value":2480},"That's the purpose of the ",{"type":415,"tag":468,"props":2482,"children":2484},{"className":2483},[],[2485],{"type":420,"value":2322},{"type":420,"value":1766},{"type":415,"tag":434,"props":2488,"children":2489},{"icon":436},[2490],{"type":415,"tag":416,"props":2491,"children":2492},{},[2493,2495],{"type":420,"value":2494},"Please note that all this configuration (as well as the Uris of each client) can be loaded from the configuration like this ",{"type":415,"tag":468,"props":2496,"children":2498},{"className":2497},[],[2499],{"type":420,"value":2500},"clientBuilder.AddTableServiceClient(builder.Configuration.GetSection(\"Inventory:Tables\"));",{"type":415,"tag":482,"props":2502,"children":2504},{"id":2503},"use-named-clients-for-different-azure-resources",[2505],{"type":420,"value":2506},"Use named clients for different Azure resources",{"type":415,"tag":416,"props":2508,"children":2509},{},[2510,2512,2518],{"type":420,"value":2511},"Usually, you only need one client of each SDK in your application. Let's say you have multiple Azure Storage tables that are used in your application, you will only need to have one ",{"type":415,"tag":468,"props":2513,"children":2515},{"className":2514},[],[2516],{"type":420,"value":2517},"TableServiceClient",{"type":420,"value":2519},". However, if you are interacting with tables in two different storage accounts, you will need multiple table clients.",{"type":415,"tag":416,"props":2521,"children":2522},{},[2523],{"type":420,"value":2524},"To do that you can register your clients with a specific name:",{"type":415,"tag":523,"props":2526,"children":2528},{"className":525,"code":2527,"language":326,"meta":401,"style":401},"builder.Services.AddAzureClients(clientBuilder =>\n{\n    clientBuilder.AddTableServiceClient(builder.Configuration.GetSection(\"Shop:Inventory\"))\n        .WithName(\"Shop\");\n    clientBuilder.AddTableServiceClient(builder.Configuration.GetSection(\"Warehouse:Inventory\"))\n        .WithName(\"Warehouse\");\n}\n",[2529],{"type":415,"tag":468,"props":2530,"children":2531},{"__ignoreMap":401},[2532,2567,2574,2635,2668,2728,2760],{"type":415,"tag":532,"props":2533,"children":2534},{"class":534,"line":535},[2535,2539,2543,2547,2551,2555,2559,2563],{"type":415,"tag":532,"props":2536,"children":2537},{"style":545},[2538],{"type":420,"value":683},{"type":415,"tag":532,"props":2540,"children":2541},{"style":551},[2542],{"type":420,"value":432},{"type":415,"tag":532,"props":2544,"children":2545},{"style":545},[2546],{"type":420,"value":692},{"type":415,"tag":532,"props":2548,"children":2549},{"style":551},[2550],{"type":420,"value":432},{"type":415,"tag":532,"props":2552,"children":2553},{"style":656},[2554],{"type":420,"value":741},{"type":415,"tag":532,"props":2556,"children":2557},{"style":551},[2558],{"type":420,"value":664},{"type":415,"tag":532,"props":2560,"children":2561},{"style":631},[2562],{"type":420,"value":750},{"type":415,"tag":532,"props":2564,"children":2565},{"style":551},[2566],{"type":420,"value":755},{"type":415,"tag":532,"props":2568,"children":2569},{"class":534,"line":566},[2570],{"type":415,"tag":532,"props":2571,"children":2572},{"style":551},[2573],{"type":420,"value":764},{"type":415,"tag":532,"props":2575,"children":2576},{"class":534,"line":583},[2577,2581,2585,2589,2593,2597,2601,2605,2609,2614,2618,2622,2627,2631],{"type":415,"tag":532,"props":2578,"children":2579},{"style":545},[2580],{"type":420,"value":773},{"type":415,"tag":532,"props":2582,"children":2583},{"style":551},[2584],{"type":420,"value":432},{"type":415,"tag":532,"props":2586,"children":2587},{"style":656},[2588],{"type":420,"value":1574},{"type":415,"tag":532,"props":2590,"children":2591},{"style":551},[2592],{"type":420,"value":664},{"type":415,"tag":532,"props":2594,"children":2595},{"style":545},[2596],{"type":420,"value":683},{"type":415,"tag":532,"props":2598,"children":2599},{"style":551},[2600],{"type":420,"value":432},{"type":415,"tag":532,"props":2602,"children":2603},{"style":545},[2604],{"type":420,"value":263},{"type":415,"tag":532,"props":2606,"children":2607},{"style":551},[2608],{"type":420,"value":432},{"type":415,"tag":532,"props":2610,"children":2611},{"style":656},[2612],{"type":420,"value":2613},"GetSection",{"type":415,"tag":532,"props":2615,"children":2616},{"style":551},[2617],{"type":420,"value":664},{"type":415,"tag":532,"props":2619,"children":2620},{"style":551},[2621],{"type":420,"value":801},{"type":415,"tag":532,"props":2623,"children":2624},{"style":804},[2625],{"type":420,"value":2626},"Shop:Inventory",{"type":415,"tag":532,"props":2628,"children":2629},{"style":551},[2630],{"type":420,"value":801},{"type":415,"tag":532,"props":2632,"children":2633},{"style":551},[2634],{"type":420,"value":1299},{"type":415,"tag":532,"props":2636,"children":2637},{"class":534,"line":617},[2638,2642,2647,2651,2655,2660,2664],{"type":415,"tag":532,"props":2639,"children":2640},{"style":551},[2641],{"type":420,"value":1532},{"type":415,"tag":532,"props":2643,"children":2644},{"style":656},[2645],{"type":420,"value":2646},"WithName",{"type":415,"tag":532,"props":2648,"children":2649},{"style":551},[2650],{"type":420,"value":664},{"type":415,"tag":532,"props":2652,"children":2653},{"style":551},[2654],{"type":420,"value":801},{"type":415,"tag":532,"props":2656,"children":2657},{"style":804},[2658],{"type":420,"value":2659},"Shop",{"type":415,"tag":532,"props":2661,"children":2662},{"style":551},[2663],{"type":420,"value":801},{"type":415,"tag":532,"props":2665,"children":2666},{"style":551},[2667],{"type":420,"value":674},{"type":415,"tag":532,"props":2669,"children":2670},{"class":534,"line":627},[2671,2675,2679,2683,2687,2691,2695,2699,2703,2707,2711,2715,2720,2724],{"type":415,"tag":532,"props":2672,"children":2673},{"style":545},[2674],{"type":420,"value":773},{"type":415,"tag":532,"props":2676,"children":2677},{"style":551},[2678],{"type":420,"value":432},{"type":415,"tag":532,"props":2680,"children":2681},{"style":656},[2682],{"type":420,"value":1574},{"type":415,"tag":532,"props":2684,"children":2685},{"style":551},[2686],{"type":420,"value":664},{"type":415,"tag":532,"props":2688,"children":2689},{"style":545},[2690],{"type":420,"value":683},{"type":415,"tag":532,"props":2692,"children":2693},{"style":551},[2694],{"type":420,"value":432},{"type":415,"tag":532,"props":2696,"children":2697},{"style":545},[2698],{"type":420,"value":263},{"type":415,"tag":532,"props":2700,"children":2701},{"style":551},[2702],{"type":420,"value":432},{"type":415,"tag":532,"props":2704,"children":2705},{"style":656},[2706],{"type":420,"value":2613},{"type":415,"tag":532,"props":2708,"children":2709},{"style":551},[2710],{"type":420,"value":664},{"type":415,"tag":532,"props":2712,"children":2713},{"style":551},[2714],{"type":420,"value":801},{"type":415,"tag":532,"props":2716,"children":2717},{"style":804},[2718],{"type":420,"value":2719},"Warehouse:Inventory",{"type":415,"tag":532,"props":2721,"children":2722},{"style":551},[2723],{"type":420,"value":801},{"type":415,"tag":532,"props":2725,"children":2726},{"style":551},[2727],{"type":420,"value":1299},{"type":415,"tag":532,"props":2729,"children":2730},{"class":534,"line":677},[2731,2735,2739,2743,2747,2752,2756],{"type":415,"tag":532,"props":2732,"children":2733},{"style":551},[2734],{"type":420,"value":1532},{"type":415,"tag":532,"props":2736,"children":2737},{"style":656},[2738],{"type":420,"value":2646},{"type":415,"tag":532,"props":2740,"children":2741},{"style":551},[2742],{"type":420,"value":664},{"type":415,"tag":532,"props":2744,"children":2745},{"style":551},[2746],{"type":420,"value":801},{"type":415,"tag":532,"props":2748,"children":2749},{"style":804},[2750],{"type":420,"value":2751},"Warehouse",{"type":415,"tag":532,"props":2753,"children":2754},{"style":551},[2755],{"type":420,"value":801},{"type":415,"tag":532,"props":2757,"children":2758},{"style":551},[2759],{"type":420,"value":674},{"type":415,"tag":532,"props":2761,"children":2762},{"class":534,"line":719},[2763],{"type":415,"tag":532,"props":2764,"children":2765},{"style":551},[2766],{"type":420,"value":1379},{"type":415,"tag":416,"props":2768,"children":2769},{},[2770],{"type":420,"value":2771},"This way, you will be able to retrieve the specific client you need in your code:",{"type":415,"tag":523,"props":2773,"children":2775},{"className":525,"code":2774,"language":326,"meta":401,"style":401},"public class WarehouseDeliveryService\n{\n    private readonly TableServiceClient _tableServiceClient;\n\n    public WarehouseDeliveryService(IAzureClientFactory\u003CTableServiceClient> azureClientFactory)\n    {\n        _tableServiceClient = azureClientFactory.CreateClient(\"Warehouse\");\n    }\n}\n",[2776],{"type":415,"tag":468,"props":2777,"children":2778},{"__ignoreMap":401},[2779,2795,2802,2827,2834,2876,2883,2928,2935],{"type":415,"tag":532,"props":2780,"children":2781},{"class":534,"line":535},[2782,2786,2790],{"type":415,"tag":532,"props":2783,"children":2784},{"style":954},[2785],{"type":420,"value":957},{"type":415,"tag":532,"props":2787,"children":2788},{"style":631},[2789],{"type":420,"value":962},{"type":415,"tag":532,"props":2791,"children":2792},{"style":631},[2793],{"type":420,"value":2794}," WarehouseDeliveryService\n",{"type":415,"tag":532,"props":2796,"children":2797},{"class":534,"line":566},[2798],{"type":415,"tag":532,"props":2799,"children":2800},{"style":551},[2801],{"type":420,"value":764},{"type":415,"tag":532,"props":2803,"children":2804},{"class":534,"line":583},[2805,2809,2813,2818,2823],{"type":415,"tag":532,"props":2806,"children":2807},{"style":954},[2808],{"type":420,"value":992},{"type":415,"tag":532,"props":2810,"children":2811},{"style":954},[2812],{"type":420,"value":997},{"type":415,"tag":532,"props":2814,"children":2815},{"style":631},[2816],{"type":420,"value":2817}," TableServiceClient",{"type":415,"tag":532,"props":2819,"children":2820},{"style":631},[2821],{"type":420,"value":2822}," _tableServiceClient",{"type":415,"tag":532,"props":2824,"children":2825},{"style":551},[2826],{"type":420,"value":563},{"type":415,"tag":532,"props":2828,"children":2829},{"class":534,"line":617},[2830],{"type":415,"tag":532,"props":2831,"children":2832},{"emptyLinePlaceholder":621},[2833],{"type":420,"value":624},{"type":415,"tag":532,"props":2835,"children":2836},{"class":534,"line":627},[2837,2841,2846,2850,2855,2859,2863,2867,2872],{"type":415,"tag":532,"props":2838,"children":2839},{"style":954},[2840],{"type":420,"value":1064},{"type":415,"tag":532,"props":2842,"children":2843},{"style":656},[2844],{"type":420,"value":2845}," WarehouseDeliveryService",{"type":415,"tag":532,"props":2847,"children":2848},{"style":551},[2849],{"type":420,"value":664},{"type":415,"tag":532,"props":2851,"children":2852},{"style":631},[2853],{"type":420,"value":2854},"IAzureClientFactory",{"type":415,"tag":532,"props":2856,"children":2857},{"style":551},[2858],{"type":420,"value":706},{"type":415,"tag":532,"props":2860,"children":2861},{"style":631},[2862],{"type":420,"value":2517},{"type":415,"tag":532,"props":2864,"children":2865},{"style":551},[2866],{"type":420,"value":1015},{"type":415,"tag":532,"props":2868,"children":2869},{"style":631},[2870],{"type":420,"value":2871}," azureClientFactory",{"type":415,"tag":532,"props":2873,"children":2874},{"style":551},[2875],{"type":420,"value":1113},{"type":415,"tag":532,"props":2877,"children":2878},{"class":534,"line":677},[2879],{"type":415,"tag":532,"props":2880,"children":2881},{"style":551},[2882],{"type":420,"value":1121},{"type":415,"tag":532,"props":2884,"children":2885},{"class":534,"line":719},[2886,2891,2895,2899,2903,2908,2912,2916,2920,2924],{"type":415,"tag":532,"props":2887,"children":2888},{"style":545},[2889],{"type":420,"value":2890},"        _tableServiceClient ",{"type":415,"tag":532,"props":2892,"children":2893},{"style":551},[2894],{"type":420,"value":1134},{"type":415,"tag":532,"props":2896,"children":2897},{"style":545},[2898],{"type":420,"value":2871},{"type":415,"tag":532,"props":2900,"children":2901},{"style":551},[2902],{"type":420,"value":432},{"type":415,"tag":532,"props":2904,"children":2905},{"style":656},[2906],{"type":420,"value":2907},"CreateClient",{"type":415,"tag":532,"props":2909,"children":2910},{"style":551},[2911],{"type":420,"value":664},{"type":415,"tag":532,"props":2913,"children":2914},{"style":551},[2915],{"type":420,"value":801},{"type":415,"tag":532,"props":2917,"children":2918},{"style":804},[2919],{"type":420,"value":2751},{"type":415,"tag":532,"props":2921,"children":2922},{"style":551},[2923],{"type":420,"value":801},{"type":415,"tag":532,"props":2925,"children":2926},{"style":551},[2927],{"type":420,"value":674},{"type":415,"tag":532,"props":2929,"children":2930},{"class":534,"line":758},[2931],{"type":415,"tag":532,"props":2932,"children":2933},{"style":551},[2934],{"type":420,"value":1170},{"type":415,"tag":532,"props":2936,"children":2937},{"class":534,"line":767},[2938],{"type":415,"tag":532,"props":2939,"children":2940},{"style":551},[2941],{"type":420,"value":1379},{"type":415,"tag":482,"props":2943,"children":2945},{"id":2944},"register-a-custom-client-factory",[2946],{"type":420,"value":2947},"Register a custom client factory",{"type":415,"tag":416,"props":2949,"children":2950},{},[2951,2953,2960,2962,2968],{"type":420,"value":2952},"If you have ",{"type":415,"tag":423,"props":2954,"children":2957},{"href":2955,"rel":2956},"https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/extensions/Microsoft.Extensions.Azure/README.md#registering-a-custom-client-factory",[427],[2958],{"type":420,"value":2959},"specific needs",{"type":420,"value":2961},", the ",{"type":415,"tag":468,"props":2963,"children":2965},{"className":2964},[],[2966],{"type":420,"value":2967},"AddClient",{"type":420,"value":2969}," method can help you register your Azure client while letting you control how you instantiate the client.",{"type":415,"tag":416,"props":2971,"children":2972},{},[2973,2975,2981,2983,2989,2991,2996,2998,3005,3007,3012],{"type":420,"value":2974},"For instance, the Azure Cosmos Db .NET SDK is not built on the same foundation (",{"type":415,"tag":468,"props":2976,"children":2978},{"className":2977},[],[2979],{"type":420,"value":2980},"Azure.Core",{"type":420,"value":2982},") as the other SDKs. So at the time of writing, there is no ",{"type":415,"tag":468,"props":2984,"children":2986},{"className":2985},[],[2987],{"type":420,"value":2988},"AddCosmosServiceClient",{"type":420,"value":2990}," you can use in the ",{"type":415,"tag":468,"props":2992,"children":2994},{"className":2993},[],[2995],{"type":420,"value":741},{"type":420,"value":2997}," (there is an ",{"type":415,"tag":423,"props":2999,"children":3002},{"href":3000,"rel":3001},"https://github.com/Azure/azure-cosmos-dotnet-v3/issues/4002",[427],[3003],{"type":420,"value":3004},"issue",{"type":420,"value":3006}," about that though). However, you can use the ",{"type":415,"tag":468,"props":3008,"children":3010},{"className":3009},[],[3011],{"type":420,"value":2967},{"type":420,"value":3013}," I've just mentioned.",{"type":415,"tag":523,"props":3015,"children":3017},{"className":525,"code":3016,"language":326,"meta":401,"style":401},"builder.Services.AddOptions\u003CCosmosDbConfiguration>().BindConfiguration(\"Warehouse:CosmosDb\");\nbuilder.Services.AddAzureClients(clientBuilder =>\n{\n    clientBuilder.AddClient\u003CCosmosClient, CosmosClientOptions>((_, _, serviceProvider) =>\n    {\n        var cosmosConfiguration = serviceProvider.GetRequiredService\u003CIOptions\u003CCosmosDbConfiguration>>().Value;\n        return new CosmosClientBuilder(cosmosConfiguration.Endpoint, cosmosConfiguration.AuthKey)\n            .WithSerializerOptions(new () { PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase })\n            .Build();\n    }).WithName(\"Warehouse\");\n}\n",[3018],{"type":415,"tag":468,"props":3019,"children":3020},{"__ignoreMap":401},[3021,3085,3120,3127,3196,3203,3264,3321,3376,3391,3423],{"type":415,"tag":532,"props":3022,"children":3023},{"class":534,"line":535},[3024,3028,3032,3036,3040,3045,3049,3054,3059,3064,3068,3072,3077,3081],{"type":415,"tag":532,"props":3025,"children":3026},{"style":545},[3027],{"type":420,"value":683},{"type":415,"tag":532,"props":3029,"children":3030},{"style":551},[3031],{"type":420,"value":432},{"type":415,"tag":532,"props":3033,"children":3034},{"style":545},[3035],{"type":420,"value":692},{"type":415,"tag":532,"props":3037,"children":3038},{"style":551},[3039],{"type":420,"value":432},{"type":415,"tag":532,"props":3041,"children":3042},{"style":656},[3043],{"type":420,"value":3044},"AddOptions",{"type":415,"tag":532,"props":3046,"children":3047},{"style":551},[3048],{"type":420,"value":706},{"type":415,"tag":532,"props":3050,"children":3051},{"style":631},[3052],{"type":420,"value":3053},"CosmosDbConfiguration",{"type":415,"tag":532,"props":3055,"children":3056},{"style":551},[3057],{"type":420,"value":3058},">().",{"type":415,"tag":532,"props":3060,"children":3061},{"style":656},[3062],{"type":420,"value":3063},"BindConfiguration",{"type":415,"tag":532,"props":3065,"children":3066},{"style":551},[3067],{"type":420,"value":664},{"type":415,"tag":532,"props":3069,"children":3070},{"style":551},[3071],{"type":420,"value":801},{"type":415,"tag":532,"props":3073,"children":3074},{"style":804},[3075],{"type":420,"value":3076},"Warehouse:CosmosDb",{"type":415,"tag":532,"props":3078,"children":3079},{"style":551},[3080],{"type":420,"value":801},{"type":415,"tag":532,"props":3082,"children":3083},{"style":551},[3084],{"type":420,"value":674},{"type":415,"tag":532,"props":3086,"children":3087},{"class":534,"line":566},[3088,3092,3096,3100,3104,3108,3112,3116],{"type":415,"tag":532,"props":3089,"children":3090},{"style":545},[3091],{"type":420,"value":683},{"type":415,"tag":532,"props":3093,"children":3094},{"style":551},[3095],{"type":420,"value":432},{"type":415,"tag":532,"props":3097,"children":3098},{"style":545},[3099],{"type":420,"value":692},{"type":415,"tag":532,"props":3101,"children":3102},{"style":551},[3103],{"type":420,"value":432},{"type":415,"tag":532,"props":3105,"children":3106},{"style":656},[3107],{"type":420,"value":741},{"type":415,"tag":532,"props":3109,"children":3110},{"style":551},[3111],{"type":420,"value":664},{"type":415,"tag":532,"props":3113,"children":3114},{"style":631},[3115],{"type":420,"value":750},{"type":415,"tag":532,"props":3117,"children":3118},{"style":551},[3119],{"type":420,"value":755},{"type":415,"tag":532,"props":3121,"children":3122},{"class":534,"line":583},[3123],{"type":415,"tag":532,"props":3124,"children":3125},{"style":551},[3126],{"type":420,"value":764},{"type":415,"tag":532,"props":3128,"children":3129},{"class":534,"line":617},[3130,3134,3138,3142,3146,3151,3155,3160,3165,3170,3174,3179,3183,3188,3192],{"type":415,"tag":532,"props":3131,"children":3132},{"style":545},[3133],{"type":420,"value":773},{"type":415,"tag":532,"props":3135,"children":3136},{"style":551},[3137],{"type":420,"value":432},{"type":415,"tag":532,"props":3139,"children":3140},{"style":656},[3141],{"type":420,"value":2967},{"type":415,"tag":532,"props":3143,"children":3144},{"style":551},[3145],{"type":420,"value":706},{"type":415,"tag":532,"props":3147,"children":3148},{"style":631},[3149],{"type":420,"value":3150},"CosmosClient",{"type":415,"tag":532,"props":3152,"children":3153},{"style":551},[3154],{"type":420,"value":1099},{"type":415,"tag":532,"props":3156,"children":3157},{"style":631},[3158],{"type":420,"value":3159}," CosmosClientOptions",{"type":415,"tag":532,"props":3161,"children":3162},{"style":551},[3163],{"type":420,"value":3164},">((",{"type":415,"tag":532,"props":3166,"children":3167},{"style":631},[3168],{"type":420,"value":3169},"_",{"type":415,"tag":532,"props":3171,"children":3172},{"style":551},[3173],{"type":420,"value":1099},{"type":415,"tag":532,"props":3175,"children":3176},{"style":631},[3177],{"type":420,"value":3178}," _",{"type":415,"tag":532,"props":3180,"children":3181},{"style":551},[3182],{"type":420,"value":1099},{"type":415,"tag":532,"props":3184,"children":3185},{"style":631},[3186],{"type":420,"value":3187}," serviceProvider",{"type":415,"tag":532,"props":3189,"children":3190},{"style":551},[3191],{"type":420,"value":1349},{"type":415,"tag":532,"props":3193,"children":3194},{"style":551},[3195],{"type":420,"value":755},{"type":415,"tag":532,"props":3197,"children":3198},{"class":534,"line":627},[3199],{"type":415,"tag":532,"props":3200,"children":3201},{"style":551},[3202],{"type":420,"value":1121},{"type":415,"tag":532,"props":3204,"children":3205},{"class":534,"line":677},[3206,3211,3216,3220,3224,3228,3233,3237,3242,3246,3250,3255,3260],{"type":415,"tag":532,"props":3207,"children":3208},{"style":631},[3209],{"type":420,"value":3210},"        var",{"type":415,"tag":532,"props":3212,"children":3213},{"style":631},[3214],{"type":420,"value":3215}," cosmosConfiguration",{"type":415,"tag":532,"props":3217,"children":3218},{"style":551},[3219],{"type":420,"value":644},{"type":415,"tag":532,"props":3221,"children":3222},{"style":545},[3223],{"type":420,"value":3187},{"type":415,"tag":532,"props":3225,"children":3226},{"style":551},[3227],{"type":420,"value":432},{"type":415,"tag":532,"props":3229,"children":3230},{"style":656},[3231],{"type":420,"value":3232},"GetRequiredService",{"type":415,"tag":532,"props":3234,"children":3235},{"style":551},[3236],{"type":420,"value":706},{"type":415,"tag":532,"props":3238,"children":3239},{"style":631},[3240],{"type":420,"value":3241},"IOptions",{"type":415,"tag":532,"props":3243,"children":3244},{"style":551},[3245],{"type":420,"value":706},{"type":415,"tag":532,"props":3247,"children":3248},{"style":631},[3249],{"type":420,"value":3053},{"type":415,"tag":532,"props":3251,"children":3252},{"style":551},[3253],{"type":420,"value":3254},">>().",{"type":415,"tag":532,"props":3256,"children":3257},{"style":545},[3258],{"type":420,"value":3259},"Value",{"type":415,"tag":532,"props":3261,"children":3262},{"style":551},[3263],{"type":420,"value":563},{"type":415,"tag":532,"props":3265,"children":3266},{"class":534,"line":719},[3267,3272,3277,3282,3286,3291,3295,3300,3304,3308,3312,3317],{"type":415,"tag":532,"props":3268,"children":3269},{"style":1241},[3270],{"type":420,"value":3271},"        return",{"type":415,"tag":532,"props":3273,"children":3274},{"style":551},[3275],{"type":420,"value":3276}," new",{"type":415,"tag":532,"props":3278,"children":3279},{"style":631},[3280],{"type":420,"value":3281}," CosmosClientBuilder",{"type":415,"tag":532,"props":3283,"children":3284},{"style":551},[3285],{"type":420,"value":664},{"type":415,"tag":532,"props":3287,"children":3288},{"style":545},[3289],{"type":420,"value":3290},"cosmosConfiguration",{"type":415,"tag":532,"props":3292,"children":3293},{"style":551},[3294],{"type":420,"value":432},{"type":415,"tag":532,"props":3296,"children":3297},{"style":545},[3298],{"type":420,"value":3299},"Endpoint",{"type":415,"tag":532,"props":3301,"children":3302},{"style":551},[3303],{"type":420,"value":1099},{"type":415,"tag":532,"props":3305,"children":3306},{"style":545},[3307],{"type":420,"value":3215},{"type":415,"tag":532,"props":3309,"children":3310},{"style":551},[3311],{"type":420,"value":432},{"type":415,"tag":532,"props":3313,"children":3314},{"style":545},[3315],{"type":420,"value":3316},"AuthKey",{"type":415,"tag":532,"props":3318,"children":3319},{"style":551},[3320],{"type":420,"value":1113},{"type":415,"tag":532,"props":3322,"children":3323},{"class":534,"line":758},[3324,3329,3334,3338,3343,3348,3353,3357,3362,3366,3371],{"type":415,"tag":532,"props":3325,"children":3326},{"style":551},[3327],{"type":420,"value":3328},"            .",{"type":415,"tag":532,"props":3330,"children":3331},{"style":656},[3332],{"type":420,"value":3333},"WithSerializerOptions",{"type":415,"tag":532,"props":3335,"children":3336},{"style":551},[3337],{"type":420,"value":787},{"type":415,"tag":532,"props":3339,"children":3340},{"style":551},[3341],{"type":420,"value":3342}," ()",{"type":415,"tag":532,"props":3344,"children":3345},{"style":551},[3346],{"type":420,"value":3347}," {",{"type":415,"tag":532,"props":3349,"children":3350},{"style":545},[3351],{"type":420,"value":3352}," PropertyNamingPolicy ",{"type":415,"tag":532,"props":3354,"children":3355},{"style":551},[3356],{"type":420,"value":1134},{"type":415,"tag":532,"props":3358,"children":3359},{"style":545},[3360],{"type":420,"value":3361}," CosmosPropertyNamingPolicy",{"type":415,"tag":532,"props":3363,"children":3364},{"style":551},[3365],{"type":420,"value":432},{"type":415,"tag":532,"props":3367,"children":3368},{"style":545},[3369],{"type":420,"value":3370},"CamelCase ",{"type":415,"tag":532,"props":3372,"children":3373},{"style":551},[3374],{"type":420,"value":3375},"})\n",{"type":415,"tag":532,"props":3377,"children":3378},{"class":534,"line":767},[3379,3383,3387],{"type":415,"tag":532,"props":3380,"children":3381},{"style":551},[3382],{"type":420,"value":3328},{"type":415,"tag":532,"props":3384,"children":3385},{"style":656},[3386],{"type":420,"value":894},{"type":415,"tag":532,"props":3388,"children":3389},{"style":551},[3390],{"type":420,"value":899},{"type":415,"tag":532,"props":3392,"children":3393},{"class":534,"line":819},[3394,3399,3403,3407,3411,3415,3419],{"type":415,"tag":532,"props":3395,"children":3396},{"style":551},[3397],{"type":420,"value":3398},"    }).",{"type":415,"tag":532,"props":3400,"children":3401},{"style":656},[3402],{"type":420,"value":2646},{"type":415,"tag":532,"props":3404,"children":3405},{"style":551},[3406],{"type":420,"value":664},{"type":415,"tag":532,"props":3408,"children":3409},{"style":551},[3410],{"type":420,"value":801},{"type":415,"tag":532,"props":3412,"children":3413},{"style":804},[3414],{"type":420,"value":2751},{"type":415,"tag":532,"props":3416,"children":3417},{"style":551},[3418],{"type":420,"value":801},{"type":415,"tag":532,"props":3420,"children":3421},{"style":551},[3422],{"type":420,"value":674},{"type":415,"tag":532,"props":3424,"children":3425},{"class":534,"line":850},[3426],{"type":415,"tag":532,"props":3427,"children":3428},{"style":551},[3429],{"type":420,"value":1379},{"type":415,"tag":416,"props":3431,"children":3432},{},[3433,3435,3440],{"type":420,"value":3434},"You can note that using the ",{"type":415,"tag":468,"props":3436,"children":3438},{"className":3437},[],[3439],{"type":420,"value":2967},{"type":420,"value":3441}," method allows us to take profit from the named clients' feature.",{"type":415,"tag":482,"props":3443,"children":3445},{"id":3444},"wrapping-up",[3446],{"type":420,"value":3447},"Wrapping up",{"type":415,"tag":416,"props":3449,"children":3450},{},[3451,3453,3462],{"type":420,"value":3452},"As you have seen, the use of the ",{"type":415,"tag":423,"props":3454,"children":3456},{"href":464,"rel":3455},[427],[3457],{"type":415,"tag":468,"props":3458,"children":3460},{"className":3459},[],[3461],{"type":420,"value":473},{"type":420,"value":3463}," package simplifies the registration and configuration of Azure clients. While providing you with a consistent way of handling the dependency injection for Azure SDKs, it also allows you to easily customize the authentication and other options available.",{"type":415,"tag":416,"props":3465,"children":3466},{},[3467],{"type":420,"value":3468},"I hope you learned something. Don't hesitate to share your tips or what you like about the Azure SDKs in the comments.",{"type":415,"tag":3470,"props":3471,"children":3472},"style",{},[3473],{"type":420,"value":3474},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":401,"searchDepth":566,"depth":566,"links":3476},[3477,3478,3479,3480,3481,3482],{"id":484,"depth":566,"text":487},{"id":1421,"depth":566,"text":1424},{"id":1751,"depth":566,"text":1754},{"id":2503,"depth":566,"text":2506},{"id":2944,"depth":566,"text":2947},{"id":3444,"depth":566,"text":3447},"markdown","content:1.posts:59.azure-sdk-di.md","content","1.posts/59.azure-sdk-di.md","md",{"_path":67,"_dir":399,"_draft":400,"_partial":400,"_locale":401,"title":66,"description":3489,"lead":3490,"date":3491,"image":3492,"badge":3494,"tags":3495,"body":3496,"_type":3483,"_id":5920,"_source":3485,"_file":5921,"_extension":3487},"In Microsoft.Data.SqlClient v3.0.0, a new authentication mode Active Directory Default has been released. Let's see what this means when querying an Azure SQL Database from some C# code.","Talking about Active Directory Default authentication mode for SqlClient.","2021-06-22T00:00:00.000Z",{"src":3493},"/images/cloud-azure_1.jpg",{"label":408},[252,299,302,228,225,236],{"type":412,"children":3497,"toc":5909},[3498,3519,3542,3547,3553,3574,3698,3709,3714,3737,3742,3748,3753,3758,3771,3783,3986,4025,4030,4043,4077,4155,4171,4177,4182,4189,4203,5207,5212,5247,5252,5267,5273,5287,5300,5793,5798,5858,5870,5886,5892,5905],{"type":415,"tag":416,"props":3499,"children":3500},{},[3501,3503,3509,3511,3517],{"type":420,"value":3502},"In ",{"type":415,"tag":468,"props":3504,"children":3506},{"className":3505},[],[3507],{"type":420,"value":3508},"Microsoft.Data.SqlClient",{"type":420,"value":3510}," v3.0.0, a new authentication mode ",{"type":415,"tag":468,"props":3512,"children":3514},{"className":3513},[],[3515],{"type":420,"value":3516},"Active Directory Default",{"type":420,"value":3518}," has been released. Let's see what this means when querying an Azure SQL Database from some C# code.",{"type":415,"tag":434,"props":3520,"children":3521},{"icon":1382},[3522],{"type":415,"tag":416,"props":3523,"children":3524},{},[3525,3527,3532,3534,3540],{"type":420,"value":3526},"If you do not have heard about ",{"type":415,"tag":468,"props":3528,"children":3530},{"className":3529},[],[3531],{"type":420,"value":3508},{"type":420,"value":3533},", it is the new data provider for Microsoft SQL Server and Azure SQL Database which supports both .NET Framework and .NET Core and replace the old ",{"type":415,"tag":468,"props":3535,"children":3537},{"className":3536},[],[3538],{"type":420,"value":3539},"System.Data.SqlClient",{"type":420,"value":3541}," components.",{"type":415,"tag":416,"props":3543,"children":3544},{},[3545],{"type":420,"value":3546},"But first, let's talk about how we used to do that before.",{"type":415,"tag":482,"props":3548,"children":3550},{"id":3549},"the-traditional-way-using-a-secret-connection-string",[3551],{"type":420,"value":3552},"The traditional way: using a secret connection string",{"type":415,"tag":416,"props":3554,"children":3555},{},[3556,3558,3564,3566,3572],{"type":420,"value":3557},"The ",{"type":415,"tag":468,"props":3559,"children":3561},{"className":3560},[],[3562],{"type":420,"value":3563},"traditional way",{"type":420,"value":3565}," to connect to an Azure SQL database from an application in C# is to provide to the ",{"type":415,"tag":468,"props":3567,"children":3569},{"className":3568},[],[3570],{"type":420,"value":3571},"SqlConnection",{"type":420,"value":3573}," constructor a connection string that contains a username and a password. The corresponding C# code is quite simple:",{"type":415,"tag":523,"props":3575,"children":3577},{"className":525,"code":3576,"language":326,"meta":401,"style":401},"var connectionString = \"Server=server-testingmsi6499.database.windows.net; Database=database-testingmsi6499;User ID=globalSqlAdmin;Password=MySecretPassword;\");\n\nusing (var sqlConnection = new SqlConnection(connectionString));\nawait connection.OpenAsync();\n",[3578],{"type":415,"tag":468,"props":3579,"children":3580},{"__ignoreMap":401},[3581,3619,3626,3672],{"type":415,"tag":532,"props":3582,"children":3583},{"class":534,"line":535},[3584,3588,3593,3597,3602,3607,3611,3615],{"type":415,"tag":532,"props":3585,"children":3586},{"style":631},[3587],{"type":420,"value":634},{"type":415,"tag":532,"props":3589,"children":3590},{"style":631},[3591],{"type":420,"value":3592}," connectionString",{"type":415,"tag":532,"props":3594,"children":3595},{"style":551},[3596],{"type":420,"value":644},{"type":415,"tag":532,"props":3598,"children":3599},{"style":551},[3600],{"type":420,"value":3601}," \"",{"type":415,"tag":532,"props":3603,"children":3604},{"style":804},[3605],{"type":420,"value":3606},"Server=server-testingmsi6499.database.windows.net; Database=database-testingmsi6499;User ID=globalSqlAdmin;Password=MySecretPassword;",{"type":415,"tag":532,"props":3608,"children":3609},{"style":551},[3610],{"type":420,"value":801},{"type":415,"tag":532,"props":3612,"children":3613},{"style":545},[3614],{"type":420,"value":1349},{"type":415,"tag":532,"props":3616,"children":3617},{"style":551},[3618],{"type":420,"value":563},{"type":415,"tag":532,"props":3620,"children":3621},{"class":534,"line":566},[3622],{"type":415,"tag":532,"props":3623,"children":3624},{"emptyLinePlaceholder":621},[3625],{"type":420,"value":624},{"type":415,"tag":532,"props":3627,"children":3628},{"class":534,"line":583},[3629,3633,3637,3641,3646,3650,3654,3659,3663,3668],{"type":415,"tag":532,"props":3630,"children":3631},{"style":1241},[3632],{"type":420,"value":542},{"type":415,"tag":532,"props":3634,"children":3635},{"style":551},[3636],{"type":420,"value":1249},{"type":415,"tag":532,"props":3638,"children":3639},{"style":631},[3640],{"type":420,"value":634},{"type":415,"tag":532,"props":3642,"children":3643},{"style":631},[3644],{"type":420,"value":3645}," sqlConnection",{"type":415,"tag":532,"props":3647,"children":3648},{"style":551},[3649],{"type":420,"value":644},{"type":415,"tag":532,"props":3651,"children":3652},{"style":551},[3653],{"type":420,"value":3276},{"type":415,"tag":532,"props":3655,"children":3656},{"style":631},[3657],{"type":420,"value":3658}," SqlConnection",{"type":415,"tag":532,"props":3660,"children":3661},{"style":551},[3662],{"type":420,"value":664},{"type":415,"tag":532,"props":3664,"children":3665},{"style":545},[3666],{"type":420,"value":3667},"connectionString",{"type":415,"tag":532,"props":3669,"children":3670},{"style":551},[3671],{"type":420,"value":816},{"type":415,"tag":532,"props":3673,"children":3674},{"class":534,"line":617},[3675,3680,3685,3689,3694],{"type":415,"tag":532,"props":3676,"children":3677},{"style":551},[3678],{"type":420,"value":3679},"await",{"type":415,"tag":532,"props":3681,"children":3682},{"style":545},[3683],{"type":420,"value":3684}," connection",{"type":415,"tag":532,"props":3686,"children":3687},{"style":551},[3688],{"type":420,"value":432},{"type":415,"tag":532,"props":3690,"children":3691},{"style":656},[3692],{"type":420,"value":3693},"OpenAsync",{"type":415,"tag":532,"props":3695,"children":3696},{"style":551},[3697],{"type":420,"value":899},{"type":415,"tag":416,"props":3699,"children":3700},{},[3701,3703,3708],{"type":420,"value":3702},"In that case, the connection string is a secret we must secure and not just by putting it in some configuration location everyone can have access to, but by storing it in a secured place like ",{"type":415,"tag":468,"props":3704,"children":3706},{"className":3705},[],[3707],{"type":420,"value":260},{"type":420,"value":432},{"type":415,"tag":416,"props":3710,"children":3711},{},[3712],{"type":420,"value":3713},"However, even if you secure it appropriately, using a connection string with a username/password in it has some disadvantages:",{"type":415,"tag":508,"props":3715,"children":3716},{},[3717,3722,3727,3732],{"type":415,"tag":512,"props":3718,"children":3719},{},[3720],{"type":420,"value":3721},"you need to handle who has access to it (so who has access to the key vault)",{"type":415,"tag":512,"props":3723,"children":3724},{},[3725],{"type":420,"value":3726},"every application or every developer could potentially use the same connection string so auditing is not very convenient (for instance identifying in the database logs which user has run a specific transaction)",{"type":415,"tag":512,"props":3728,"children":3729},{},[3730],{"type":420,"value":3731},"you only control who has access to the connection string in the key vault, not what people do with it (share it by email, store it on their local computer, ...) so not who can access the database",{"type":415,"tag":512,"props":3733,"children":3734},{},[3735],{"type":420,"value":3736},"you need to handle the rotation of the secret, in other words, change the username/password regularly (because you can revoke the access to someone to the database, if he had access to the connection string at some point in time it is not a secret for him anymore)",{"type":415,"tag":416,"props":3738,"children":3739},{},[3740],{"type":420,"value":3741},"For all these reasons, using a secret connection string to connect to an Azure SQL Database is not the right approach.",{"type":415,"tag":482,"props":3743,"children":3745},{"id":3744},"the-new-way-using-azure-active-directory-authentication",[3746],{"type":420,"value":3747},"The new way: using Azure Active Directory Authentication",{"type":415,"tag":416,"props":3749,"children":3750},{},[3751],{"type":420,"value":3752},"Instead of using a secret connection string to connect to a database, the idea is to use the Azure Active Directory authentication mechanism. Azure Active Directory is the location that contains all the identities of your users and your applications in your company. So you can manage directly which identity (user or application) have access to a database.",{"type":415,"tag":416,"props":3754,"children":3755},{},[3756],{"type":420,"value":3757},"Applications or users that want to query a database will authenticate against Azure AD to retrieve an access token that will allow them to access the database using a connection string without any username nor password.",{"type":415,"tag":416,"props":3759,"children":3760},{},[3761,3763,3770],{"type":420,"value":3762},"If you want to know more about the advantages of using Azure AD authentication for connecting to an Azure SQL Database you can have a look in the ",{"type":415,"tag":423,"props":3764,"children":3767},{"href":3765,"rel":3766},"https://docs.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-overview",[427],[3768],{"type":420,"value":3769},"official documentation",{"type":420,"value":432},{"type":415,"tag":416,"props":3772,"children":3773},{},[3774,3776,3781],{"type":420,"value":3775},"In the code we can remove the user id and password from the connection string but we have to retrieve an Azure AD access token and pass it to the ",{"type":415,"tag":468,"props":3777,"children":3779},{"className":3778},[],[3780],{"type":420,"value":3571},{"type":420,"value":3782}," instance:",{"type":415,"tag":523,"props":3784,"children":3786},{"className":525,"code":3785,"language":326,"meta":401,"style":401},"var accessToken = await new DefaultAzureCredential().GetTokenAsync(new TokenRequestContext(new string[] { \"https://database.windows.net//.default\" }));\nusing var connection = new SqlConnection(\"Server=server-testingmsi6499.database.windows.net; Database=database-testingmsi6499;\")\n{\n    AccessToken = accessToken.Token\n};\nawait connection.OpenAsync();\n",[3787],{"type":415,"tag":468,"props":3788,"children":3789},{"__ignoreMap":401},[3790,3874,3923,3930,3955,3963],{"type":415,"tag":532,"props":3791,"children":3792},{"class":534,"line":535},[3793,3797,3802,3806,3811,3815,3819,3824,3829,3833,3838,3842,3847,3852,3856,3860,3865,3869],{"type":415,"tag":532,"props":3794,"children":3795},{"style":631},[3796],{"type":420,"value":634},{"type":415,"tag":532,"props":3798,"children":3799},{"style":631},[3800],{"type":420,"value":3801}," accessToken",{"type":415,"tag":532,"props":3803,"children":3804},{"style":551},[3805],{"type":420,"value":644},{"type":415,"tag":532,"props":3807,"children":3808},{"style":551},[3809],{"type":420,"value":3810}," await",{"type":415,"tag":532,"props":3812,"children":3813},{"style":551},[3814],{"type":420,"value":3276},{"type":415,"tag":532,"props":3816,"children":3817},{"style":631},[3818],{"type":420,"value":842},{"type":415,"tag":532,"props":3820,"children":3821},{"style":551},[3822],{"type":420,"value":3823},"().",{"type":415,"tag":532,"props":3825,"children":3826},{"style":656},[3827],{"type":420,"value":3828},"GetTokenAsync",{"type":415,"tag":532,"props":3830,"children":3831},{"style":551},[3832],{"type":420,"value":787},{"type":415,"tag":532,"props":3834,"children":3835},{"style":631},[3836],{"type":420,"value":3837}," TokenRequestContext",{"type":415,"tag":532,"props":3839,"children":3840},{"style":551},[3841],{"type":420,"value":787},{"type":415,"tag":532,"props":3843,"children":3844},{"style":551},[3845],{"type":420,"value":3846}," string",{"type":415,"tag":532,"props":3848,"children":3849},{"style":551},[3850],{"type":420,"value":3851},"[]",{"type":415,"tag":532,"props":3853,"children":3854},{"style":551},[3855],{"type":420,"value":3347},{"type":415,"tag":532,"props":3857,"children":3858},{"style":551},[3859],{"type":420,"value":3601},{"type":415,"tag":532,"props":3861,"children":3862},{"style":804},[3863],{"type":420,"value":3864},"https://database.windows.net//.default",{"type":415,"tag":532,"props":3866,"children":3867},{"style":551},[3868],{"type":420,"value":801},{"type":415,"tag":532,"props":3870,"children":3871},{"style":551},[3872],{"type":420,"value":3873}," }));\n",{"type":415,"tag":532,"props":3875,"children":3876},{"class":534,"line":566},[3877,3881,3886,3890,3894,3898,3902,3906,3910,3915,3919],{"type":415,"tag":532,"props":3878,"children":3879},{"style":1241},[3880],{"type":420,"value":542},{"type":415,"tag":532,"props":3882,"children":3883},{"style":631},[3884],{"type":420,"value":3885}," var",{"type":415,"tag":532,"props":3887,"children":3888},{"style":631},[3889],{"type":420,"value":3684},{"type":415,"tag":532,"props":3891,"children":3892},{"style":551},[3893],{"type":420,"value":644},{"type":415,"tag":532,"props":3895,"children":3896},{"style":551},[3897],{"type":420,"value":3276},{"type":415,"tag":532,"props":3899,"children":3900},{"style":631},[3901],{"type":420,"value":3658},{"type":415,"tag":532,"props":3903,"children":3904},{"style":551},[3905],{"type":420,"value":664},{"type":415,"tag":532,"props":3907,"children":3908},{"style":551},[3909],{"type":420,"value":801},{"type":415,"tag":532,"props":3911,"children":3912},{"style":804},[3913],{"type":420,"value":3914},"Server=server-testingmsi6499.database.windows.net; Database=database-testingmsi6499;",{"type":415,"tag":532,"props":3916,"children":3917},{"style":551},[3918],{"type":420,"value":801},{"type":415,"tag":532,"props":3920,"children":3921},{"style":551},[3922],{"type":420,"value":1113},{"type":415,"tag":532,"props":3924,"children":3925},{"class":534,"line":583},[3926],{"type":415,"tag":532,"props":3927,"children":3928},{"style":551},[3929],{"type":420,"value":764},{"type":415,"tag":532,"props":3931,"children":3932},{"class":534,"line":617},[3933,3938,3942,3946,3950],{"type":415,"tag":532,"props":3934,"children":3935},{"style":545},[3936],{"type":420,"value":3937},"    AccessToken ",{"type":415,"tag":532,"props":3939,"children":3940},{"style":551},[3941],{"type":420,"value":1134},{"type":415,"tag":532,"props":3943,"children":3944},{"style":545},[3945],{"type":420,"value":3801},{"type":415,"tag":532,"props":3947,"children":3948},{"style":551},[3949],{"type":420,"value":432},{"type":415,"tag":532,"props":3951,"children":3952},{"style":545},[3953],{"type":420,"value":3954},"Token\n",{"type":415,"tag":532,"props":3956,"children":3957},{"class":534,"line":627},[3958],{"type":415,"tag":532,"props":3959,"children":3960},{"style":551},[3961],{"type":420,"value":3962},"};\n",{"type":415,"tag":532,"props":3964,"children":3965},{"class":534,"line":677},[3966,3970,3974,3978,3982],{"type":415,"tag":532,"props":3967,"children":3968},{"style":551},[3969],{"type":420,"value":3679},{"type":415,"tag":532,"props":3971,"children":3972},{"style":545},[3973],{"type":420,"value":3684},{"type":415,"tag":532,"props":3975,"children":3976},{"style":551},[3977],{"type":420,"value":432},{"type":415,"tag":532,"props":3979,"children":3980},{"style":656},[3981],{"type":420,"value":3693},{"type":415,"tag":532,"props":3983,"children":3984},{"style":551},[3985],{"type":420,"value":899},{"type":415,"tag":416,"props":3987,"children":3988},{},[3989,3991,3998,4000,4006,4008,4015,4017,4023],{"type":420,"value":3990},"The code is using the ",{"type":415,"tag":423,"props":3992,"children":3995},{"href":3993,"rel":3994},"https://docs.microsoft.com/en-us/dotnet/api/overview/azure/identity-readme",[427],[3996],{"type":420,"value":3997},"Azure Identity library",{"type":420,"value":3999}," which as the documentation says \"",{"type":415,"tag":4001,"props":4002,"children":4003},"em",{},[4004],{"type":420,"value":4005},"provides Azure Active Directory token authentication support across the Azure SDK",{"type":420,"value":4007},"\". It is the recommended way to get an Azure token although you may have seen code that uses another library ",{"type":415,"tag":423,"props":4009,"children":4012},{"href":4010,"rel":4011},"https://www.nuget.org/packages/Microsoft.Azure.Services.AppAuthentication",[427],[4013],{"type":420,"value":4014},"Microsoft.Azure.Services.AppAuthentication",{"type":420,"value":4016}," to do the same thing. The class ",{"type":415,"tag":468,"props":4018,"children":4020},{"className":4019},[],[4021],{"type":420,"value":4022},"DefaultAzureCredential",{"type":420,"value":4024}," from Azure Identity library combines multiple authentication mechanisms (like Managed Identities, Visual Studio, Azure CLI ...) that will be tried in order to retrieve a token so it is a practical class that can handle most of the scenarios.",{"type":415,"tag":416,"props":4026,"children":4027},{},[4028],{"type":420,"value":4029},"Therefore, provided that you have granted access to your database to the user you are using locally (in Visual Studio, in vs code, or in Azure CLI) and to the managed identity of your application in Azure (App Service or Azure Function for instance) the same code will work both locally and in Azure.",{"type":415,"tag":482,"props":4031,"children":4033},{"id":4032},"here-comes-active-directory-default-authentication-mode",[4034,4036,4041],{"type":420,"value":4035},"Here comes ",{"type":415,"tag":468,"props":4037,"children":4039},{"className":4038},[],[4040],{"type":420,"value":3516},{"type":420,"value":4042}," authentication mode",{"type":415,"tag":416,"props":4044,"children":4045},{},[4046,4048,4053,4055,4060,4062,4068,4070,4075],{"type":420,"value":4047},"We have seen that using Azure Active Directory Authentication was a better solution than using a connection string with secrets in it to connect to a database. However, it involves manually retrieving an Azure AD token which makes the code a bit more complex to read. That is exactly why ",{"type":415,"tag":468,"props":4049,"children":4051},{"className":4050},[],[4052],{"type":420,"value":3516},{"type":420,"value":4054}," new authentication mode was introduced in ",{"type":415,"tag":468,"props":4056,"children":4058},{"className":4057},[],[4059],{"type":420,"value":3508},{"type":420,"value":4061}," v3.0.0. Under the hood, ",{"type":415,"tag":468,"props":4063,"children":4065},{"className":4064},[],[4066],{"type":420,"value":4067},"SqlClient",{"type":420,"value":4069}," does the same thing that we were showing previously so we don't have to do it ourselves: just specifying the authentication mode to ",{"type":415,"tag":468,"props":4071,"children":4073},{"className":4072},[],[4074],{"type":420,"value":3516},{"type":420,"value":4076}," in the connection string is enough to make it work.",{"type":415,"tag":523,"props":4078,"children":4080},{"className":525,"code":4079,"language":326,"meta":401,"style":401},"using var connection = new SqlConnection(\"Server=server-testingmsi6499.database.windows.net; Authentication=Active Directory Default; Database=database-testingmsi6499;\");\nawait connection.OpenAsync();\n",[4081],{"type":415,"tag":468,"props":4082,"children":4083},{"__ignoreMap":401},[4084,4132],{"type":415,"tag":532,"props":4085,"children":4086},{"class":534,"line":535},[4087,4091,4095,4099,4103,4107,4111,4115,4119,4124,4128],{"type":415,"tag":532,"props":4088,"children":4089},{"style":1241},[4090],{"type":420,"value":542},{"type":415,"tag":532,"props":4092,"children":4093},{"style":631},[4094],{"type":420,"value":3885},{"type":415,"tag":532,"props":4096,"children":4097},{"style":631},[4098],{"type":420,"value":3684},{"type":415,"tag":532,"props":4100,"children":4101},{"style":551},[4102],{"type":420,"value":644},{"type":415,"tag":532,"props":4104,"children":4105},{"style":551},[4106],{"type":420,"value":3276},{"type":415,"tag":532,"props":4108,"children":4109},{"style":631},[4110],{"type":420,"value":3658},{"type":415,"tag":532,"props":4112,"children":4113},{"style":551},[4114],{"type":420,"value":664},{"type":415,"tag":532,"props":4116,"children":4117},{"style":551},[4118],{"type":420,"value":801},{"type":415,"tag":532,"props":4120,"children":4121},{"style":804},[4122],{"type":420,"value":4123},"Server=server-testingmsi6499.database.windows.net; Authentication=Active Directory Default; Database=database-testingmsi6499;",{"type":415,"tag":532,"props":4125,"children":4126},{"style":551},[4127],{"type":420,"value":801},{"type":415,"tag":532,"props":4129,"children":4130},{"style":551},[4131],{"type":420,"value":674},{"type":415,"tag":532,"props":4133,"children":4134},{"class":534,"line":566},[4135,4139,4143,4147,4151],{"type":415,"tag":532,"props":4136,"children":4137},{"style":551},[4138],{"type":420,"value":3679},{"type":415,"tag":532,"props":4140,"children":4141},{"style":545},[4142],{"type":420,"value":3684},{"type":415,"tag":532,"props":4144,"children":4145},{"style":551},[4146],{"type":420,"value":432},{"type":415,"tag":532,"props":4148,"children":4149},{"style":656},[4150],{"type":420,"value":3693},{"type":415,"tag":532,"props":4152,"children":4153},{"style":551},[4154],{"type":420,"value":899},{"type":415,"tag":434,"props":4156,"children":4157},{"icon":1382},[4158],{"type":415,"tag":416,"props":4159,"children":4160},{},[4161,4163,4170],{"type":420,"value":4162},"There are other Azure Active Directory authentication methods available, you can find them in the documentation ",{"type":415,"tag":423,"props":4164,"children":4167},{"href":4165,"rel":4166},"https://docs.microsoft.com/en-us/sql/connect/ado-net/sql/azure-active-directory-authentication?view=sql-server-ver15#using-active-directory-password-authentication",[427],[4168],{"type":420,"value":4169},"here",{"type":420,"value":432},{"type":415,"tag":482,"props":4172,"children":4174},{"id":4173},"a-complete-example",[4175],{"type":420,"value":4176},"A complete example",{"type":415,"tag":416,"props":4178,"children":4179},{},[4180],{"type":420,"value":4181},"Enough theory, what if you want to quickly test this by yourself?",{"type":415,"tag":4183,"props":4184,"children":4186},"h3",{"id":4185},"a-bit-of-azure-cli-to-initialize-the-database",[4187],{"type":420,"value":4188},"A bit of Azure CLI to initialize the database",{"type":415,"tag":416,"props":4190,"children":4191},{},[4192,4194,4201],{"type":420,"value":4193},"I took an ",{"type":415,"tag":423,"props":4195,"children":4198},{"href":4196,"rel":4197},"https://docs.microsoft.com/en-us/azure/azure-sql/database/scripts/create-and-configure-database-cli",[427],[4199],{"type":420,"value":4200},"Azure CLI sample script",{"type":420,"value":4202}," from Microsoft and modify it a little to configure a database with all that is necessary to use Azure Active Directory to connect my user to it.",{"type":415,"tag":523,"props":4204,"children":4208},{"className":4205,"code":4206,"language":4207,"meta":401,"style":401},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","#!/bin/bash\nlocation=\"West Europe\" # to change with your preferred location\nrandomIdentifier=testingmsi${RANDOM:0:5}\n\nresourceGroup=\"resource-$randomIdentifier\"\nserver=\"server-$randomIdentifier\"\ndatabase=\"database-$randomIdentifier\"\n\nlogin=\"globalSqlAdmin\"\npassword=\"P@ssw0rdToChange!\" # to change to have a more secured password\n\n# Retrieve your public IP.\n# Replace by your local machine IP if you are executing this script from cloud shell.\nstartIP=$(dig +short myip.opendns.com @resolver1.opendns.com)\nendIP=$startIP\n\n# Retrieve your current logged-in user to be used as SQL server admin. \n# Change with another user id if you want another user to be an admin.\nazureaduser=$(az ad signed-in-user show --query \"objectId\" -o tsv)\n\necho \"Creating $resourceGroup...\"\naz group create --name $resourceGroup --location \"$location\"\n\necho \"Creating $server in $location...\"\naz sql server create --name $server --resource-group $resourceGroup --location \"$location\" --admin-user $login --admin-password $password\n\necho \"Configuring firewall...\"\naz sql server firewall-rule create --resource-group $resourceGroup --server $server -n AllowYourIp --start-ip-address $startIP --end-ip-address $endIP\n\necho \"Creating $database on $server...\"\naz sql db create --resource-group $resourceGroup --server $server --name $database --sample-name AdventureWorksLT --service-objective Basic --zone-redundant false\n\necho \"Creating AD admin in sql server...\"\naz sql server ad-admin create --resource-group $resourceGroup --server-name $server --display-name ADMIN --object-id $azureaduser\n\necho \"Database connection string to use: \\\"Server=$server.database.windows.net; Authentication=Active Directory Default; Database=$database;\\\"\"\n","bash",[4209],{"type":415,"tag":468,"props":4210,"children":4211},{"__ignoreMap":401},[4212,4221,4251,4300,4307,4338,4367,4396,4403,4428,4458,4465,4473,4481,4518,4535,4542,4550,4558,4622,4630,4662,4708,4716,4754,4830,4838,4859,4932,4940,4978,5055,5063,5084,5146,5154],{"type":415,"tag":532,"props":4213,"children":4214},{"class":534,"line":535},[4215],{"type":415,"tag":532,"props":4216,"children":4218},{"style":4217},"--shiki-light:#90A4AE;--shiki-default:#546E7A;--shiki-dark:#676E95;--shiki-light-font-style:italic;--shiki-default-font-style:italic;--shiki-dark-font-style:italic",[4219],{"type":420,"value":4220},"#!/bin/bash\n",{"type":415,"tag":532,"props":4222,"children":4223},{"class":534,"line":566},[4224,4229,4233,4237,4242,4246],{"type":415,"tag":532,"props":4225,"children":4226},{"style":545},[4227],{"type":420,"value":4228},"location",{"type":415,"tag":532,"props":4230,"children":4231},{"style":551},[4232],{"type":420,"value":1134},{"type":415,"tag":532,"props":4234,"children":4235},{"style":551},[4236],{"type":420,"value":801},{"type":415,"tag":532,"props":4238,"children":4239},{"style":804},[4240],{"type":420,"value":4241},"West Europe",{"type":415,"tag":532,"props":4243,"children":4244},{"style":551},[4245],{"type":420,"value":801},{"type":415,"tag":532,"props":4247,"children":4248},{"style":4217},[4249],{"type":420,"value":4250}," # to change with your preferred location\n",{"type":415,"tag":532,"props":4252,"children":4253},{"class":534,"line":583},[4254,4259,4263,4268,4273,4278,4282,4287,4291,4296],{"type":415,"tag":532,"props":4255,"children":4256},{"style":545},[4257],{"type":420,"value":4258},"randomIdentifier",{"type":415,"tag":532,"props":4260,"children":4261},{"style":551},[4262],{"type":420,"value":1134},{"type":415,"tag":532,"props":4264,"children":4265},{"style":804},[4266],{"type":420,"value":4267},"testingmsi",{"type":415,"tag":532,"props":4269,"children":4270},{"style":551},[4271],{"type":420,"value":4272},"${",{"type":415,"tag":532,"props":4274,"children":4275},{"style":545},[4276],{"type":420,"value":4277},"RANDOM",{"type":415,"tag":532,"props":4279,"children":4280},{"style":551},[4281],{"type":420,"value":1290},{"type":415,"tag":532,"props":4283,"children":4284},{"style":545},[4285],{"type":420,"value":4286},"0",{"type":415,"tag":532,"props":4288,"children":4289},{"style":551},[4290],{"type":420,"value":1290},{"type":415,"tag":532,"props":4292,"children":4293},{"style":545},[4294],{"type":420,"value":4295},"5",{"type":415,"tag":532,"props":4297,"children":4298},{"style":551},[4299],{"type":420,"value":1379},{"type":415,"tag":532,"props":4301,"children":4302},{"class":534,"line":617},[4303],{"type":415,"tag":532,"props":4304,"children":4305},{"emptyLinePlaceholder":621},[4306],{"type":420,"value":624},{"type":415,"tag":532,"props":4308,"children":4309},{"class":534,"line":627},[4310,4315,4319,4323,4328,4333],{"type":415,"tag":532,"props":4311,"children":4312},{"style":545},[4313],{"type":420,"value":4314},"resourceGroup",{"type":415,"tag":532,"props":4316,"children":4317},{"style":551},[4318],{"type":420,"value":1134},{"type":415,"tag":532,"props":4320,"children":4321},{"style":551},[4322],{"type":420,"value":801},{"type":415,"tag":532,"props":4324,"children":4325},{"style":804},[4326],{"type":420,"value":4327},"resource-",{"type":415,"tag":532,"props":4329,"children":4330},{"style":545},[4331],{"type":420,"value":4332},"$randomIdentifier",{"type":415,"tag":532,"props":4334,"children":4335},{"style":551},[4336],{"type":420,"value":4337},"\"\n",{"type":415,"tag":532,"props":4339,"children":4340},{"class":534,"line":677},[4341,4346,4350,4354,4359,4363],{"type":415,"tag":532,"props":4342,"children":4343},{"style":545},[4344],{"type":420,"value":4345},"server",{"type":415,"tag":532,"props":4347,"children":4348},{"style":551},[4349],{"type":420,"value":1134},{"type":415,"tag":532,"props":4351,"children":4352},{"style":551},[4353],{"type":420,"value":801},{"type":415,"tag":532,"props":4355,"children":4356},{"style":804},[4357],{"type":420,"value":4358},"server-",{"type":415,"tag":532,"props":4360,"children":4361},{"style":545},[4362],{"type":420,"value":4332},{"type":415,"tag":532,"props":4364,"children":4365},{"style":551},[4366],{"type":420,"value":4337},{"type":415,"tag":532,"props":4368,"children":4369},{"class":534,"line":719},[4370,4375,4379,4383,4388,4392],{"type":415,"tag":532,"props":4371,"children":4372},{"style":545},[4373],{"type":420,"value":4374},"database",{"type":415,"tag":532,"props":4376,"children":4377},{"style":551},[4378],{"type":420,"value":1134},{"type":415,"tag":532,"props":4380,"children":4381},{"style":551},[4382],{"type":420,"value":801},{"type":415,"tag":532,"props":4384,"children":4385},{"style":804},[4386],{"type":420,"value":4387},"database-",{"type":415,"tag":532,"props":4389,"children":4390},{"style":545},[4391],{"type":420,"value":4332},{"type":415,"tag":532,"props":4393,"children":4394},{"style":551},[4395],{"type":420,"value":4337},{"type":415,"tag":532,"props":4397,"children":4398},{"class":534,"line":758},[4399],{"type":415,"tag":532,"props":4400,"children":4401},{"emptyLinePlaceholder":621},[4402],{"type":420,"value":624},{"type":415,"tag":532,"props":4404,"children":4405},{"class":534,"line":767},[4406,4411,4415,4419,4424],{"type":415,"tag":532,"props":4407,"children":4408},{"style":545},[4409],{"type":420,"value":4410},"login",{"type":415,"tag":532,"props":4412,"children":4413},{"style":551},[4414],{"type":420,"value":1134},{"type":415,"tag":532,"props":4416,"children":4417},{"style":551},[4418],{"type":420,"value":801},{"type":415,"tag":532,"props":4420,"children":4421},{"style":804},[4422],{"type":420,"value":4423},"globalSqlAdmin",{"type":415,"tag":532,"props":4425,"children":4426},{"style":551},[4427],{"type":420,"value":4337},{"type":415,"tag":532,"props":4429,"children":4430},{"class":534,"line":819},[4431,4436,4440,4444,4449,4453],{"type":415,"tag":532,"props":4432,"children":4433},{"style":545},[4434],{"type":420,"value":4435},"password",{"type":415,"tag":532,"props":4437,"children":4438},{"style":551},[4439],{"type":420,"value":1134},{"type":415,"tag":532,"props":4441,"children":4442},{"style":551},[4443],{"type":420,"value":801},{"type":415,"tag":532,"props":4445,"children":4446},{"style":804},[4447],{"type":420,"value":4448},"P@ssw0rdToChange!",{"type":415,"tag":532,"props":4450,"children":4451},{"style":551},[4452],{"type":420,"value":801},{"type":415,"tag":532,"props":4454,"children":4455},{"style":4217},[4456],{"type":420,"value":4457}," # to change to have a more secured password\n",{"type":415,"tag":532,"props":4459,"children":4460},{"class":534,"line":850},[4461],{"type":415,"tag":532,"props":4462,"children":4463},{"emptyLinePlaceholder":621},[4464],{"type":420,"value":624},{"type":415,"tag":532,"props":4466,"children":4467},{"class":534,"line":859},[4468],{"type":415,"tag":532,"props":4469,"children":4470},{"style":4217},[4471],{"type":420,"value":4472},"# Retrieve your public IP.\n",{"type":415,"tag":532,"props":4474,"children":4475},{"class":534,"line":867},[4476],{"type":415,"tag":532,"props":4477,"children":4478},{"style":4217},[4479],{"type":420,"value":4480},"# Replace by your local machine IP if you are executing this script from cloud shell.\n",{"type":415,"tag":532,"props":4482,"children":4483},{"class":534,"line":902},[4484,4489,4494,4499,4504,4509,4514],{"type":415,"tag":532,"props":4485,"children":4486},{"style":545},[4487],{"type":420,"value":4488},"startIP",{"type":415,"tag":532,"props":4490,"children":4491},{"style":551},[4492],{"type":420,"value":4493},"=$(",{"type":415,"tag":532,"props":4495,"children":4496},{"style":631},[4497],{"type":420,"value":4498},"dig",{"type":415,"tag":532,"props":4500,"children":4501},{"style":804},[4502],{"type":420,"value":4503}," +short",{"type":415,"tag":532,"props":4505,"children":4506},{"style":804},[4507],{"type":420,"value":4508}," myip.opendns.com",{"type":415,"tag":532,"props":4510,"children":4511},{"style":804},[4512],{"type":420,"value":4513}," @resolver1.opendns.com",{"type":415,"tag":532,"props":4515,"children":4516},{"style":551},[4517],{"type":420,"value":1113},{"type":415,"tag":532,"props":4519,"children":4520},{"class":534,"line":1302},[4521,4526,4530],{"type":415,"tag":532,"props":4522,"children":4523},{"style":545},[4524],{"type":420,"value":4525},"endIP",{"type":415,"tag":532,"props":4527,"children":4528},{"style":551},[4529],{"type":420,"value":1134},{"type":415,"tag":532,"props":4531,"children":4532},{"style":545},[4533],{"type":420,"value":4534},"$startIP\n",{"type":415,"tag":532,"props":4536,"children":4537},{"class":534,"line":1311},[4538],{"type":415,"tag":532,"props":4539,"children":4540},{"emptyLinePlaceholder":621},[4541],{"type":420,"value":624},{"type":415,"tag":532,"props":4543,"children":4544},{"class":534,"line":1356},[4545],{"type":415,"tag":532,"props":4546,"children":4547},{"style":4217},[4548],{"type":420,"value":4549},"# Retrieve your current logged-in user to be used as SQL server admin. \n",{"type":415,"tag":532,"props":4551,"children":4552},{"class":534,"line":1365},[4553],{"type":415,"tag":532,"props":4554,"children":4555},{"style":4217},[4556],{"type":420,"value":4557},"# Change with another user id if you want another user to be an admin.\n",{"type":415,"tag":532,"props":4559,"children":4560},{"class":534,"line":1373},[4561,4566,4570,4575,4580,4585,4590,4595,4599,4604,4608,4613,4618],{"type":415,"tag":532,"props":4562,"children":4563},{"style":545},[4564],{"type":420,"value":4565},"azureaduser",{"type":415,"tag":532,"props":4567,"children":4568},{"style":551},[4569],{"type":420,"value":4493},{"type":415,"tag":532,"props":4571,"children":4572},{"style":631},[4573],{"type":420,"value":4574},"az",{"type":415,"tag":532,"props":4576,"children":4577},{"style":804},[4578],{"type":420,"value":4579}," ad",{"type":415,"tag":532,"props":4581,"children":4582},{"style":804},[4583],{"type":420,"value":4584}," signed-in-user",{"type":415,"tag":532,"props":4586,"children":4587},{"style":804},[4588],{"type":420,"value":4589}," show",{"type":415,"tag":532,"props":4591,"children":4592},{"style":804},[4593],{"type":420,"value":4594}," --query",{"type":415,"tag":532,"props":4596,"children":4597},{"style":551},[4598],{"type":420,"value":3601},{"type":415,"tag":532,"props":4600,"children":4601},{"style":804},[4602],{"type":420,"value":4603},"objectId",{"type":415,"tag":532,"props":4605,"children":4606},{"style":551},[4607],{"type":420,"value":801},{"type":415,"tag":532,"props":4609,"children":4610},{"style":804},[4611],{"type":420,"value":4612}," -o",{"type":415,"tag":532,"props":4614,"children":4615},{"style":804},[4616],{"type":420,"value":4617}," tsv",{"type":415,"tag":532,"props":4619,"children":4620},{"style":551},[4621],{"type":420,"value":1113},{"type":415,"tag":532,"props":4623,"children":4625},{"class":534,"line":4624},20,[4626],{"type":415,"tag":532,"props":4627,"children":4628},{"emptyLinePlaceholder":621},[4629],{"type":420,"value":624},{"type":415,"tag":532,"props":4631,"children":4633},{"class":534,"line":4632},21,[4634,4639,4643,4648,4653,4658],{"type":415,"tag":532,"props":4635,"children":4636},{"style":656},[4637],{"type":420,"value":4638},"echo",{"type":415,"tag":532,"props":4640,"children":4641},{"style":551},[4642],{"type":420,"value":3601},{"type":415,"tag":532,"props":4644,"children":4645},{"style":804},[4646],{"type":420,"value":4647},"Creating ",{"type":415,"tag":532,"props":4649,"children":4650},{"style":545},[4651],{"type":420,"value":4652},"$resourceGroup",{"type":415,"tag":532,"props":4654,"children":4655},{"style":804},[4656],{"type":420,"value":4657},"...",{"type":415,"tag":532,"props":4659,"children":4660},{"style":551},[4661],{"type":420,"value":4337},{"type":415,"tag":532,"props":4663,"children":4665},{"class":534,"line":4664},22,[4666,4670,4675,4680,4685,4690,4695,4699,4704],{"type":415,"tag":532,"props":4667,"children":4668},{"style":631},[4669],{"type":420,"value":4574},{"type":415,"tag":532,"props":4671,"children":4672},{"style":804},[4673],{"type":420,"value":4674}," group",{"type":415,"tag":532,"props":4676,"children":4677},{"style":804},[4678],{"type":420,"value":4679}," create",{"type":415,"tag":532,"props":4681,"children":4682},{"style":804},[4683],{"type":420,"value":4684}," --name",{"type":415,"tag":532,"props":4686,"children":4687},{"style":545},[4688],{"type":420,"value":4689}," $resourceGroup ",{"type":415,"tag":532,"props":4691,"children":4692},{"style":804},[4693],{"type":420,"value":4694},"--location",{"type":415,"tag":532,"props":4696,"children":4697},{"style":551},[4698],{"type":420,"value":3601},{"type":415,"tag":532,"props":4700,"children":4701},{"style":545},[4702],{"type":420,"value":4703},"$location",{"type":415,"tag":532,"props":4705,"children":4706},{"style":551},[4707],{"type":420,"value":4337},{"type":415,"tag":532,"props":4709,"children":4711},{"class":534,"line":4710},23,[4712],{"type":415,"tag":532,"props":4713,"children":4714},{"emptyLinePlaceholder":621},[4715],{"type":420,"value":624},{"type":415,"tag":532,"props":4717,"children":4719},{"class":534,"line":4718},24,[4720,4724,4728,4732,4737,4742,4746,4750],{"type":415,"tag":532,"props":4721,"children":4722},{"style":656},[4723],{"type":420,"value":4638},{"type":415,"tag":532,"props":4725,"children":4726},{"style":551},[4727],{"type":420,"value":3601},{"type":415,"tag":532,"props":4729,"children":4730},{"style":804},[4731],{"type":420,"value":4647},{"type":415,"tag":532,"props":4733,"children":4734},{"style":545},[4735],{"type":420,"value":4736},"$server",{"type":415,"tag":532,"props":4738,"children":4739},{"style":804},[4740],{"type":420,"value":4741}," in ",{"type":415,"tag":532,"props":4743,"children":4744},{"style":545},[4745],{"type":420,"value":4703},{"type":415,"tag":532,"props":4747,"children":4748},{"style":804},[4749],{"type":420,"value":4657},{"type":415,"tag":532,"props":4751,"children":4752},{"style":551},[4753],{"type":420,"value":4337},{"type":415,"tag":532,"props":4755,"children":4757},{"class":534,"line":4756},25,[4758,4762,4767,4772,4776,4780,4785,4790,4794,4798,4802,4806,4810,4815,4820,4825],{"type":415,"tag":532,"props":4759,"children":4760},{"style":631},[4761],{"type":420,"value":4574},{"type":415,"tag":532,"props":4763,"children":4764},{"style":804},[4765],{"type":420,"value":4766}," sql",{"type":415,"tag":532,"props":4768,"children":4769},{"style":804},[4770],{"type":420,"value":4771}," server",{"type":415,"tag":532,"props":4773,"children":4774},{"style":804},[4775],{"type":420,"value":4679},{"type":415,"tag":532,"props":4777,"children":4778},{"style":804},[4779],{"type":420,"value":4684},{"type":415,"tag":532,"props":4781,"children":4782},{"style":545},[4783],{"type":420,"value":4784}," $server ",{"type":415,"tag":532,"props":4786,"children":4787},{"style":804},[4788],{"type":420,"value":4789},"--resource-group",{"type":415,"tag":532,"props":4791,"children":4792},{"style":545},[4793],{"type":420,"value":4689},{"type":415,"tag":532,"props":4795,"children":4796},{"style":804},[4797],{"type":420,"value":4694},{"type":415,"tag":532,"props":4799,"children":4800},{"style":551},[4801],{"type":420,"value":3601},{"type":415,"tag":532,"props":4803,"children":4804},{"style":545},[4805],{"type":420,"value":4703},{"type":415,"tag":532,"props":4807,"children":4808},{"style":551},[4809],{"type":420,"value":801},{"type":415,"tag":532,"props":4811,"children":4812},{"style":804},[4813],{"type":420,"value":4814}," --admin-user",{"type":415,"tag":532,"props":4816,"children":4817},{"style":545},[4818],{"type":420,"value":4819}," $login ",{"type":415,"tag":532,"props":4821,"children":4822},{"style":804},[4823],{"type":420,"value":4824},"--admin-password",{"type":415,"tag":532,"props":4826,"children":4827},{"style":545},[4828],{"type":420,"value":4829}," $password\n",{"type":415,"tag":532,"props":4831,"children":4833},{"class":534,"line":4832},26,[4834],{"type":415,"tag":532,"props":4835,"children":4836},{"emptyLinePlaceholder":621},[4837],{"type":420,"value":624},{"type":415,"tag":532,"props":4839,"children":4841},{"class":534,"line":4840},27,[4842,4846,4850,4855],{"type":415,"tag":532,"props":4843,"children":4844},{"style":656},[4845],{"type":420,"value":4638},{"type":415,"tag":532,"props":4847,"children":4848},{"style":551},[4849],{"type":420,"value":3601},{"type":415,"tag":532,"props":4851,"children":4852},{"style":804},[4853],{"type":420,"value":4854},"Configuring firewall...",{"type":415,"tag":532,"props":4856,"children":4857},{"style":551},[4858],{"type":420,"value":4337},{"type":415,"tag":532,"props":4860,"children":4862},{"class":534,"line":4861},28,[4863,4867,4871,4875,4880,4884,4889,4893,4898,4902,4907,4912,4917,4922,4927],{"type":415,"tag":532,"props":4864,"children":4865},{"style":631},[4866],{"type":420,"value":4574},{"type":415,"tag":532,"props":4868,"children":4869},{"style":804},[4870],{"type":420,"value":4766},{"type":415,"tag":532,"props":4872,"children":4873},{"style":804},[4874],{"type":420,"value":4771},{"type":415,"tag":532,"props":4876,"children":4877},{"style":804},[4878],{"type":420,"value":4879}," firewall-rule",{"type":415,"tag":532,"props":4881,"children":4882},{"style":804},[4883],{"type":420,"value":4679},{"type":415,"tag":532,"props":4885,"children":4886},{"style":804},[4887],{"type":420,"value":4888}," --resource-group",{"type":415,"tag":532,"props":4890,"children":4891},{"style":545},[4892],{"type":420,"value":4689},{"type":415,"tag":532,"props":4894,"children":4895},{"style":804},[4896],{"type":420,"value":4897},"--server",{"type":415,"tag":532,"props":4899,"children":4900},{"style":545},[4901],{"type":420,"value":4784},{"type":415,"tag":532,"props":4903,"children":4904},{"style":804},[4905],{"type":420,"value":4906},"-n",{"type":415,"tag":532,"props":4908,"children":4909},{"style":804},[4910],{"type":420,"value":4911}," AllowYourIp",{"type":415,"tag":532,"props":4913,"children":4914},{"style":804},[4915],{"type":420,"value":4916}," --start-ip-address",{"type":415,"tag":532,"props":4918,"children":4919},{"style":545},[4920],{"type":420,"value":4921}," $startIP ",{"type":415,"tag":532,"props":4923,"children":4924},{"style":804},[4925],{"type":420,"value":4926},"--end-ip-address",{"type":415,"tag":532,"props":4928,"children":4929},{"style":545},[4930],{"type":420,"value":4931}," $endIP\n",{"type":415,"tag":532,"props":4933,"children":4935},{"class":534,"line":4934},29,[4936],{"type":415,"tag":532,"props":4937,"children":4938},{"emptyLinePlaceholder":621},[4939],{"type":420,"value":624},{"type":415,"tag":532,"props":4941,"children":4943},{"class":534,"line":4942},30,[4944,4948,4952,4956,4961,4966,4970,4974],{"type":415,"tag":532,"props":4945,"children":4946},{"style":656},[4947],{"type":420,"value":4638},{"type":415,"tag":532,"props":4949,"children":4950},{"style":551},[4951],{"type":420,"value":3601},{"type":415,"tag":532,"props":4953,"children":4954},{"style":804},[4955],{"type":420,"value":4647},{"type":415,"tag":532,"props":4957,"children":4958},{"style":545},[4959],{"type":420,"value":4960},"$database",{"type":415,"tag":532,"props":4962,"children":4963},{"style":804},[4964],{"type":420,"value":4965}," on ",{"type":415,"tag":532,"props":4967,"children":4968},{"style":545},[4969],{"type":420,"value":4736},{"type":415,"tag":532,"props":4971,"children":4972},{"style":804},[4973],{"type":420,"value":4657},{"type":415,"tag":532,"props":4975,"children":4976},{"style":551},[4977],{"type":420,"value":4337},{"type":415,"tag":532,"props":4979,"children":4981},{"class":534,"line":4980},31,[4982,4986,4990,4995,4999,5003,5007,5011,5015,5020,5025,5030,5035,5040,5045,5050],{"type":415,"tag":532,"props":4983,"children":4984},{"style":631},[4985],{"type":420,"value":4574},{"type":415,"tag":532,"props":4987,"children":4988},{"style":804},[4989],{"type":420,"value":4766},{"type":415,"tag":532,"props":4991,"children":4992},{"style":804},[4993],{"type":420,"value":4994}," db",{"type":415,"tag":532,"props":4996,"children":4997},{"style":804},[4998],{"type":420,"value":4679},{"type":415,"tag":532,"props":5000,"children":5001},{"style":804},[5002],{"type":420,"value":4888},{"type":415,"tag":532,"props":5004,"children":5005},{"style":545},[5006],{"type":420,"value":4689},{"type":415,"tag":532,"props":5008,"children":5009},{"style":804},[5010],{"type":420,"value":4897},{"type":415,"tag":532,"props":5012,"children":5013},{"style":545},[5014],{"type":420,"value":4784},{"type":415,"tag":532,"props":5016,"children":5017},{"style":804},[5018],{"type":420,"value":5019},"--name",{"type":415,"tag":532,"props":5021,"children":5022},{"style":545},[5023],{"type":420,"value":5024}," $database ",{"type":415,"tag":532,"props":5026,"children":5027},{"style":804},[5028],{"type":420,"value":5029},"--sample-name",{"type":415,"tag":532,"props":5031,"children":5032},{"style":804},[5033],{"type":420,"value":5034}," AdventureWorksLT",{"type":415,"tag":532,"props":5036,"children":5037},{"style":804},[5038],{"type":420,"value":5039}," --service-objective",{"type":415,"tag":532,"props":5041,"children":5042},{"style":804},[5043],{"type":420,"value":5044}," Basic",{"type":415,"tag":532,"props":5046,"children":5047},{"style":804},[5048],{"type":420,"value":5049}," --zone-redundant",{"type":415,"tag":532,"props":5051,"children":5052},{"style":551},[5053],{"type":420,"value":5054}," false\n",{"type":415,"tag":532,"props":5056,"children":5058},{"class":534,"line":5057},32,[5059],{"type":415,"tag":532,"props":5060,"children":5061},{"emptyLinePlaceholder":621},[5062],{"type":420,"value":624},{"type":415,"tag":532,"props":5064,"children":5066},{"class":534,"line":5065},33,[5067,5071,5075,5080],{"type":415,"tag":532,"props":5068,"children":5069},{"style":656},[5070],{"type":420,"value":4638},{"type":415,"tag":532,"props":5072,"children":5073},{"style":551},[5074],{"type":420,"value":3601},{"type":415,"tag":532,"props":5076,"children":5077},{"style":804},[5078],{"type":420,"value":5079},"Creating AD admin in sql server...",{"type":415,"tag":532,"props":5081,"children":5082},{"style":551},[5083],{"type":420,"value":4337},{"type":415,"tag":532,"props":5085,"children":5087},{"class":534,"line":5086},34,[5088,5092,5096,5100,5105,5109,5113,5117,5122,5126,5131,5136,5141],{"type":415,"tag":532,"props":5089,"children":5090},{"style":631},[5091],{"type":420,"value":4574},{"type":415,"tag":532,"props":5093,"children":5094},{"style":804},[5095],{"type":420,"value":4766},{"type":415,"tag":532,"props":5097,"children":5098},{"style":804},[5099],{"type":420,"value":4771},{"type":415,"tag":532,"props":5101,"children":5102},{"style":804},[5103],{"type":420,"value":5104}," ad-admin",{"type":415,"tag":532,"props":5106,"children":5107},{"style":804},[5108],{"type":420,"value":4679},{"type":415,"tag":532,"props":5110,"children":5111},{"style":804},[5112],{"type":420,"value":4888},{"type":415,"tag":532,"props":5114,"children":5115},{"style":545},[5116],{"type":420,"value":4689},{"type":415,"tag":532,"props":5118,"children":5119},{"style":804},[5120],{"type":420,"value":5121},"--server-name",{"type":415,"tag":532,"props":5123,"children":5124},{"style":545},[5125],{"type":420,"value":4784},{"type":415,"tag":532,"props":5127,"children":5128},{"style":804},[5129],{"type":420,"value":5130},"--display-name",{"type":415,"tag":532,"props":5132,"children":5133},{"style":804},[5134],{"type":420,"value":5135}," ADMIN",{"type":415,"tag":532,"props":5137,"children":5138},{"style":804},[5139],{"type":420,"value":5140}," --object-id",{"type":415,"tag":532,"props":5142,"children":5143},{"style":545},[5144],{"type":420,"value":5145}," $azureaduser\n",{"type":415,"tag":532,"props":5147,"children":5149},{"class":534,"line":5148},35,[5150],{"type":415,"tag":532,"props":5151,"children":5152},{"emptyLinePlaceholder":621},[5153],{"type":420,"value":624},{"type":415,"tag":532,"props":5155,"children":5157},{"class":534,"line":5156},36,[5158,5162,5166,5171,5176,5181,5185,5190,5194,5199,5203],{"type":415,"tag":532,"props":5159,"children":5160},{"style":656},[5161],{"type":420,"value":4638},{"type":415,"tag":532,"props":5163,"children":5164},{"style":551},[5165],{"type":420,"value":3601},{"type":415,"tag":532,"props":5167,"children":5168},{"style":804},[5169],{"type":420,"value":5170},"Database connection string to use: ",{"type":415,"tag":532,"props":5172,"children":5173},{"style":545},[5174],{"type":420,"value":5175},"\\\"",{"type":415,"tag":532,"props":5177,"children":5178},{"style":804},[5179],{"type":420,"value":5180},"Server=",{"type":415,"tag":532,"props":5182,"children":5183},{"style":545},[5184],{"type":420,"value":4736},{"type":415,"tag":532,"props":5186,"children":5187},{"style":804},[5188],{"type":420,"value":5189},".database.windows.net; Authentication=Active Directory Default; Database=",{"type":415,"tag":532,"props":5191,"children":5192},{"style":545},[5193],{"type":420,"value":4960},{"type":415,"tag":532,"props":5195,"children":5196},{"style":804},[5197],{"type":420,"value":5198},";",{"type":415,"tag":532,"props":5200,"children":5201},{"style":545},[5202],{"type":420,"value":5175},{"type":415,"tag":532,"props":5204,"children":5205},{"style":551},[5206],{"type":420,"value":4337},{"type":415,"tag":416,"props":5208,"children":5209},{},[5210],{"type":420,"value":5211},"This script should be self-explanatory if you have already played a little with Azure CLI. Basically, what it does is:",{"type":415,"tag":508,"props":5213,"children":5214},{},[5215,5220,5232,5237,5242],{"type":415,"tag":512,"props":5216,"children":5217},{},[5218],{"type":420,"value":5219},"create an azure SQL server",{"type":415,"tag":512,"props":5221,"children":5222},{},[5223,5225,5230],{"type":420,"value":5224},"configure the server firewall to allow you to query it from your local IP address (if you are executing the script from cloud shell, replace ",{"type":415,"tag":468,"props":5226,"children":5228},{"className":5227},[],[5229],{"type":420,"value":4488},{"type":420,"value":5231}," variable with your local machine IP)",{"type":415,"tag":512,"props":5233,"children":5234},{},[5235],{"type":420,"value":5236},"create an azure SQL database with already tables and data in it from the sample AdventureWorksLT",{"type":415,"tag":512,"props":5238,"children":5239},{},[5240],{"type":420,"value":5241},"set you logged in azure ad user as the AD administrator of the database",{"type":415,"tag":512,"props":5243,"children":5244},{},[5245],{"type":420,"value":5246},"write in the console the connection string to use in your C# code to access the database",{"type":415,"tag":416,"props":5248,"children":5249},{},[5250],{"type":420,"value":5251},"If you want to customize something do not hesitate to modify the scripts and especially variables like the resources location, the SQL server user/password, or the name of the resources. This is a bash script but if you want to execute it in PowerShell, all the Azure CLI commands should work fine, you just have to change the variables declarations as the syntax is different in PowerShell. If you don't have Azure CLI installed on your laptop you can use Azure Cloud Shell to execute this script.",{"type":415,"tag":434,"props":5253,"children":5254},{"icon":1382},[5255],{"type":415,"tag":416,"props":5256,"children":5257},{},[5258,5260,5266],{"type":420,"value":5259},"If you are new to Azure CLI, you can read my article ",{"type":415,"tag":423,"props":5261,"children":5264},{"href":5262,"rel":5263},"https://www.techwatching.dev/posts/welcome-azure-cli",[427],[5265],{"type":420,"value":15},{"type":420,"value":432},{"type":415,"tag":4183,"props":5268,"children":5270},{"id":5269},"querying-the-database-from-a-minima-api-in-c",[5271],{"type":420,"value":5272},"Querying the database from a minima API in C#",{"type":415,"tag":416,"props":5274,"children":5275},{},[5276,5278,5285],{"type":420,"value":5277},"Usually, I like to create a console application (with the ",{"type":415,"tag":423,"props":5279,"children":5282},{"href":5280,"rel":5281},"https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-5.0&tabs=visual-studio#worker-service-template",[427],[5283],{"type":420,"value":5284},"worker service template",{"type":420,"value":5286}," for instance) for my samples, yet this time I decided to try the new minimal APIs from .NET 6 (currently in preview).",{"type":415,"tag":416,"props":5288,"children":5289},{},[5290,5292,5298],{"type":420,"value":5291},"Minimal APIs would probably deserve an entire blog post, but let's just say a minimal API in .NET 6 allow you to build a small HTTP API with less ceremony than a classic controller-based API. As all the code can be written in a ",{"type":415,"tag":468,"props":5293,"children":5295},{"className":5294},[],[5296],{"type":420,"value":5297},"Program.cs",{"type":420,"value":5299}," file, so it's very convenient when you want to quickly build a web application without too much complexity (especially if you are new to ASP.NET Core) or if you are developing a small microservice.",{"type":415,"tag":523,"props":5301,"children":5303},{"className":525,"code":5302,"language":326,"meta":401,"style":401},"using Dapper;\nusing Microsoft.Data.SqlClient;\n\nvar builder = WebApplication.CreateBuilder(args);\nvar app = builder.Build();\n\nif (app.Environment.IsDevelopment())\n{\n    app.UseDeveloperExceptionPage();\n}\n\napp.MapGet(\"/\", async () =>\n{\n    using var connection = new SqlConnection(\"Server=server-testingmsi28497.database.windows.net; Authentication=Active Directory Default; Database=database-testingmsi28497;\");\n    var products = await connection.QueryAsync\u003CProduct>(\"SELECT TOP 10 ProductID, Name from [SalesLT].[Product]\");\n    return products;\n});\n\napp.Run();\n\npublic record Product(int ProductID, string Name);\n",[5304],{"type":415,"tag":468,"props":5305,"children":5306},{"__ignoreMap":401},[5307,5323,5355,5362,5403,5435,5442,5481,5488,5509,5516,5523,5572,5579,5628,5693,5709,5716,5723,5742,5749],{"type":415,"tag":532,"props":5308,"children":5309},{"class":534,"line":535},[5310,5314,5319],{"type":415,"tag":532,"props":5311,"children":5312},{"style":539},[5313],{"type":420,"value":542},{"type":415,"tag":532,"props":5315,"children":5316},{"style":545},[5317],{"type":420,"value":5318}," Dapper",{"type":415,"tag":532,"props":5320,"children":5321},{"style":551},[5322],{"type":420,"value":563},{"type":415,"tag":532,"props":5324,"children":5325},{"class":534,"line":566},[5326,5330,5334,5338,5343,5347,5351],{"type":415,"tag":532,"props":5327,"children":5328},{"style":539},[5329],{"type":420,"value":542},{"type":415,"tag":532,"props":5331,"children":5332},{"style":545},[5333],{"type":420,"value":593},{"type":415,"tag":532,"props":5335,"children":5336},{"style":551},[5337],{"type":420,"value":432},{"type":415,"tag":532,"props":5339,"children":5340},{"style":545},[5341],{"type":420,"value":5342},"Data",{"type":415,"tag":532,"props":5344,"children":5345},{"style":551},[5346],{"type":420,"value":432},{"type":415,"tag":532,"props":5348,"children":5349},{"style":545},[5350],{"type":420,"value":4067},{"type":415,"tag":532,"props":5352,"children":5353},{"style":551},[5354],{"type":420,"value":563},{"type":415,"tag":532,"props":5356,"children":5357},{"class":534,"line":583},[5358],{"type":415,"tag":532,"props":5359,"children":5360},{"emptyLinePlaceholder":621},[5361],{"type":420,"value":624},{"type":415,"tag":532,"props":5363,"children":5364},{"class":534,"line":617},[5365,5369,5373,5377,5382,5386,5391,5395,5399],{"type":415,"tag":532,"props":5366,"children":5367},{"style":631},[5368],{"type":420,"value":634},{"type":415,"tag":532,"props":5370,"children":5371},{"style":631},[5372],{"type":420,"value":639},{"type":415,"tag":532,"props":5374,"children":5375},{"style":551},[5376],{"type":420,"value":644},{"type":415,"tag":532,"props":5378,"children":5379},{"style":545},[5380],{"type":420,"value":5381}," WebApplication",{"type":415,"tag":532,"props":5383,"children":5384},{"style":551},[5385],{"type":420,"value":432},{"type":415,"tag":532,"props":5387,"children":5388},{"style":656},[5389],{"type":420,"value":5390},"CreateBuilder",{"type":415,"tag":532,"props":5392,"children":5393},{"style":551},[5394],{"type":420,"value":664},{"type":415,"tag":532,"props":5396,"children":5397},{"style":545},[5398],{"type":420,"value":669},{"type":415,"tag":532,"props":5400,"children":5401},{"style":551},[5402],{"type":420,"value":674},{"type":415,"tag":532,"props":5404,"children":5405},{"class":534,"line":627},[5406,5410,5415,5419,5423,5427,5431],{"type":415,"tag":532,"props":5407,"children":5408},{"style":631},[5409],{"type":420,"value":634},{"type":415,"tag":532,"props":5411,"children":5412},{"style":631},[5413],{"type":420,"value":5414}," app",{"type":415,"tag":532,"props":5416,"children":5417},{"style":551},[5418],{"type":420,"value":644},{"type":415,"tag":532,"props":5420,"children":5421},{"style":545},[5422],{"type":420,"value":639},{"type":415,"tag":532,"props":5424,"children":5425},{"style":551},[5426],{"type":420,"value":432},{"type":415,"tag":532,"props":5428,"children":5429},{"style":656},[5430],{"type":420,"value":894},{"type":415,"tag":532,"props":5432,"children":5433},{"style":551},[5434],{"type":420,"value":899},{"type":415,"tag":532,"props":5436,"children":5437},{"class":534,"line":677},[5438],{"type":415,"tag":532,"props":5439,"children":5440},{"emptyLinePlaceholder":621},[5441],{"type":420,"value":624},{"type":415,"tag":532,"props":5443,"children":5444},{"class":534,"line":719},[5445,5450,5454,5459,5463,5468,5472,5477],{"type":415,"tag":532,"props":5446,"children":5447},{"style":1241},[5448],{"type":420,"value":5449},"if",{"type":415,"tag":532,"props":5451,"children":5452},{"style":551},[5453],{"type":420,"value":1249},{"type":415,"tag":532,"props":5455,"children":5456},{"style":545},[5457],{"type":420,"value":5458},"app",{"type":415,"tag":532,"props":5460,"children":5461},{"style":551},[5462],{"type":420,"value":432},{"type":415,"tag":532,"props":5464,"children":5465},{"style":545},[5466],{"type":420,"value":5467},"Environment",{"type":415,"tag":532,"props":5469,"children":5470},{"style":551},[5471],{"type":420,"value":432},{"type":415,"tag":532,"props":5473,"children":5474},{"style":656},[5475],{"type":420,"value":5476},"IsDevelopment",{"type":415,"tag":532,"props":5478,"children":5479},{"style":551},[5480],{"type":420,"value":1882},{"type":415,"tag":532,"props":5482,"children":5483},{"class":534,"line":758},[5484],{"type":415,"tag":532,"props":5485,"children":5486},{"style":551},[5487],{"type":420,"value":764},{"type":415,"tag":532,"props":5489,"children":5490},{"class":534,"line":767},[5491,5496,5500,5505],{"type":415,"tag":532,"props":5492,"children":5493},{"style":545},[5494],{"type":420,"value":5495},"    app",{"type":415,"tag":532,"props":5497,"children":5498},{"style":551},[5499],{"type":420,"value":432},{"type":415,"tag":532,"props":5501,"children":5502},{"style":656},[5503],{"type":420,"value":5504},"UseDeveloperExceptionPage",{"type":415,"tag":532,"props":5506,"children":5507},{"style":551},[5508],{"type":420,"value":899},{"type":415,"tag":532,"props":5510,"children":5511},{"class":534,"line":819},[5512],{"type":415,"tag":532,"props":5513,"children":5514},{"style":551},[5515],{"type":420,"value":1379},{"type":415,"tag":532,"props":5517,"children":5518},{"class":534,"line":850},[5519],{"type":415,"tag":532,"props":5520,"children":5521},{"emptyLinePlaceholder":621},[5522],{"type":420,"value":624},{"type":415,"tag":532,"props":5524,"children":5525},{"class":534,"line":859},[5526,5530,5534,5539,5543,5547,5552,5556,5560,5564,5568],{"type":415,"tag":532,"props":5527,"children":5528},{"style":545},[5529],{"type":420,"value":5458},{"type":415,"tag":532,"props":5531,"children":5532},{"style":551},[5533],{"type":420,"value":432},{"type":415,"tag":532,"props":5535,"children":5536},{"style":656},[5537],{"type":420,"value":5538},"MapGet",{"type":415,"tag":532,"props":5540,"children":5541},{"style":551},[5542],{"type":420,"value":664},{"type":415,"tag":532,"props":5544,"children":5545},{"style":551},[5546],{"type":420,"value":801},{"type":415,"tag":532,"props":5548,"children":5549},{"style":804},[5550],{"type":420,"value":5551},"/",{"type":415,"tag":532,"props":5553,"children":5554},{"style":551},[5555],{"type":420,"value":801},{"type":415,"tag":532,"props":5557,"children":5558},{"style":551},[5559],{"type":420,"value":1099},{"type":415,"tag":532,"props":5561,"children":5562},{"style":954},[5563],{"type":420,"value":1195},{"type":415,"tag":532,"props":5565,"children":5566},{"style":551},[5567],{"type":420,"value":3342},{"type":415,"tag":532,"props":5569,"children":5570},{"style":551},[5571],{"type":420,"value":755},{"type":415,"tag":532,"props":5573,"children":5574},{"class":534,"line":867},[5575],{"type":415,"tag":532,"props":5576,"children":5577},{"style":551},[5578],{"type":420,"value":764},{"type":415,"tag":532,"props":5580,"children":5581},{"class":534,"line":902},[5582,5587,5591,5595,5599,5603,5607,5611,5615,5620,5624],{"type":415,"tag":532,"props":5583,"children":5584},{"style":1241},[5585],{"type":420,"value":5586},"    using",{"type":415,"tag":532,"props":5588,"children":5589},{"style":631},[5590],{"type":420,"value":3885},{"type":415,"tag":532,"props":5592,"children":5593},{"style":631},[5594],{"type":420,"value":3684},{"type":415,"tag":532,"props":5596,"children":5597},{"style":551},[5598],{"type":420,"value":644},{"type":415,"tag":532,"props":5600,"children":5601},{"style":551},[5602],{"type":420,"value":3276},{"type":415,"tag":532,"props":5604,"children":5605},{"style":631},[5606],{"type":420,"value":3658},{"type":415,"tag":532,"props":5608,"children":5609},{"style":551},[5610],{"type":420,"value":664},{"type":415,"tag":532,"props":5612,"children":5613},{"style":551},[5614],{"type":420,"value":801},{"type":415,"tag":532,"props":5616,"children":5617},{"style":804},[5618],{"type":420,"value":5619},"Server=server-testingmsi28497.database.windows.net; Authentication=Active Directory Default; Database=database-testingmsi28497;",{"type":415,"tag":532,"props":5621,"children":5622},{"style":551},[5623],{"type":420,"value":801},{"type":415,"tag":532,"props":5625,"children":5626},{"style":551},[5627],{"type":420,"value":674},{"type":415,"tag":532,"props":5629,"children":5630},{"class":534,"line":1302},[5631,5636,5641,5645,5649,5653,5657,5662,5666,5671,5676,5680,5685,5689],{"type":415,"tag":532,"props":5632,"children":5633},{"style":631},[5634],{"type":420,"value":5635},"    var",{"type":415,"tag":532,"props":5637,"children":5638},{"style":631},[5639],{"type":420,"value":5640}," products",{"type":415,"tag":532,"props":5642,"children":5643},{"style":551},[5644],{"type":420,"value":644},{"type":415,"tag":532,"props":5646,"children":5647},{"style":551},[5648],{"type":420,"value":3810},{"type":415,"tag":532,"props":5650,"children":5651},{"style":545},[5652],{"type":420,"value":3684},{"type":415,"tag":532,"props":5654,"children":5655},{"style":551},[5656],{"type":420,"value":432},{"type":415,"tag":532,"props":5658,"children":5659},{"style":656},[5660],{"type":420,"value":5661},"QueryAsync",{"type":415,"tag":532,"props":5663,"children":5664},{"style":551},[5665],{"type":420,"value":706},{"type":415,"tag":532,"props":5667,"children":5668},{"style":631},[5669],{"type":420,"value":5670},"Product",{"type":415,"tag":532,"props":5672,"children":5673},{"style":551},[5674],{"type":420,"value":5675},">(",{"type":415,"tag":532,"props":5677,"children":5678},{"style":551},[5679],{"type":420,"value":801},{"type":415,"tag":532,"props":5681,"children":5682},{"style":804},[5683],{"type":420,"value":5684},"SELECT TOP 10 ProductID, Name from [SalesLT].[Product]",{"type":415,"tag":532,"props":5686,"children":5687},{"style":551},[5688],{"type":420,"value":801},{"type":415,"tag":532,"props":5690,"children":5691},{"style":551},[5692],{"type":420,"value":674},{"type":415,"tag":532,"props":5694,"children":5695},{"class":534,"line":1311},[5696,5701,5705],{"type":415,"tag":532,"props":5697,"children":5698},{"style":1241},[5699],{"type":420,"value":5700},"    return",{"type":415,"tag":532,"props":5702,"children":5703},{"style":545},[5704],{"type":420,"value":5640},{"type":415,"tag":532,"props":5706,"children":5707},{"style":551},[5708],{"type":420,"value":563},{"type":415,"tag":532,"props":5710,"children":5711},{"class":534,"line":1356},[5712],{"type":415,"tag":532,"props":5713,"children":5714},{"style":551},[5715],{"type":420,"value":856},{"type":415,"tag":532,"props":5717,"children":5718},{"class":534,"line":1365},[5719],{"type":415,"tag":532,"props":5720,"children":5721},{"emptyLinePlaceholder":621},[5722],{"type":420,"value":624},{"type":415,"tag":532,"props":5724,"children":5725},{"class":534,"line":1373},[5726,5730,5734,5738],{"type":415,"tag":532,"props":5727,"children":5728},{"style":545},[5729],{"type":420,"value":5458},{"type":415,"tag":532,"props":5731,"children":5732},{"style":551},[5733],{"type":420,"value":432},{"type":415,"tag":532,"props":5735,"children":5736},{"style":656},[5737],{"type":420,"value":917},{"type":415,"tag":532,"props":5739,"children":5740},{"style":551},[5741],{"type":420,"value":899},{"type":415,"tag":532,"props":5743,"children":5744},{"class":534,"line":4624},[5745],{"type":415,"tag":532,"props":5746,"children":5747},{"emptyLinePlaceholder":621},[5748],{"type":420,"value":624},{"type":415,"tag":532,"props":5750,"children":5751},{"class":534,"line":4632},[5752,5756,5761,5766,5771,5776,5780,5784,5789],{"type":415,"tag":532,"props":5753,"children":5754},{"style":954},[5755],{"type":420,"value":957},{"type":415,"tag":532,"props":5757,"children":5758},{"style":631},[5759],{"type":420,"value":5760}," record",{"type":415,"tag":532,"props":5762,"children":5763},{"style":631},[5764],{"type":420,"value":5765}," Product",{"type":415,"tag":532,"props":5767,"children":5768},{"style":551},[5769],{"type":420,"value":5770},"(int",{"type":415,"tag":532,"props":5772,"children":5773},{"style":631},[5774],{"type":420,"value":5775}," ProductID",{"type":415,"tag":532,"props":5777,"children":5778},{"style":551},[5779],{"type":420,"value":1099},{"type":415,"tag":532,"props":5781,"children":5782},{"style":551},[5783],{"type":420,"value":3846},{"type":415,"tag":532,"props":5785,"children":5786},{"style":631},[5787],{"type":420,"value":5788}," Name",{"type":415,"tag":532,"props":5790,"children":5791},{"style":551},[5792],{"type":420,"value":674},{"type":415,"tag":416,"props":5794,"children":5795},{},[5796],{"type":420,"value":5797},"As you can see this code is only 26 lines long:",{"type":415,"tag":508,"props":5799,"children":5800},{},[5801,5814,5828,5840],{"type":415,"tag":512,"props":5802,"children":5803},{},[5804,5806,5812],{"type":420,"value":5805},"there is only one route, that returns the Product identifiers and names from the table ",{"type":415,"tag":468,"props":5807,"children":5809},{"className":5808},[],[5810],{"type":420,"value":5811},"[SalesLT].[Product]",{"type":420,"value":5813}," of the database created with the previous Azure CLI script",{"type":415,"tag":512,"props":5815,"children":5816},{},[5817,5819,5826],{"type":420,"value":5818},"the SQL query is done by using the micro ORM ",{"type":415,"tag":423,"props":5820,"children":5823},{"href":5821,"rel":5822},"https://github.com/DapperLib/Dapper",[427],[5824],{"type":420,"value":5825},"Dapper",{"type":420,"value":5827}," which simplifies the boilerplate code to query an SQL database while keeping performance",{"type":415,"tag":512,"props":5829,"children":5830},{},[5831,5833,5838],{"type":420,"value":5832},"the result of the SQL query is mapped to a record class ",{"type":415,"tag":468,"props":5834,"children":5836},{"className":5835},[],[5837],{"type":420,"value":5670},{"type":420,"value":5839}," which is declared in one line",{"type":415,"tag":512,"props":5841,"children":5842},{},[5843,5845,5850,5852,5857],{"type":420,"value":5844},"the code uses ",{"type":415,"tag":468,"props":5846,"children":5848},{"className":5847},[],[5849],{"type":420,"value":3508},{"type":420,"value":5851}," v3.0.0 with the ",{"type":415,"tag":468,"props":5853,"children":5855},{"className":5854},[],[5856],{"type":420,"value":3516},{"type":420,"value":4042},{"type":415,"tag":416,"props":5859,"children":5860},{},[5861],{"type":415,"tag":5862,"props":5863,"children":5869},"img",{"alt":5864,"className":5865,"src":5868},"C# code querying an SQL Database using Active Directory Default authentication mode.",[5866,5867],"rounded-lg","mx-auto","/posts/images/sqlclient_minapi_1.png",[],{"type":415,"tag":434,"props":5871,"children":5872},{"icon":1382},[5873],{"type":415,"tag":416,"props":5874,"children":5875},{},[5876,5878,5884],{"type":420,"value":5877},"To keep things simple, I am connecting to the database with the Azure AD account which is an admin of the SQL server. But I could also have assigned a role with lower permissions to my account, see ",{"type":415,"tag":423,"props":5879,"children":5882},{"href":5880,"rel":5881},"https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-connect-msi#grant-permissions-to-managed-identity",[427],[5883],{"type":420,"value":4169},{"type":420,"value":5885}," for more information on how to do that.",{"type":415,"tag":482,"props":5887,"children":5889},{"id":5888},"to-conclude",[5890],{"type":420,"value":5891},"To conclude",{"type":415,"tag":416,"props":5893,"children":5894},{},[5895,5897,5903],{"type":420,"value":5896},"While building an application interacting with Azure we often neglect to use mechanisms like Azure AD authentication that remove the need for secrets. But as we have seen in this article some libraries like ",{"type":415,"tag":468,"props":5898,"children":5900},{"className":5899},[],[5901],{"type":420,"value":5902},"Microsoft.Data.Sql.Client",{"type":420,"value":5904}," or the Azure SDKs allow us to do that quite easily. I love how connecting to an Azure SQL Database in C# is becoming more simple and more secure at the same time.",{"type":415,"tag":3470,"props":5906,"children":5907},{},[5908],{"type":420,"value":3474},{"title":401,"searchDepth":566,"depth":566,"links":5910},[5911,5912,5913,5915,5919],{"id":3549,"depth":566,"text":3552},{"id":3744,"depth":566,"text":3747},{"id":4032,"depth":566,"text":5914},"Here comes Active Directory Default authentication mode",{"id":4173,"depth":566,"text":4176,"children":5916},[5917,5918],{"id":4185,"depth":583,"text":4188},{"id":5269,"depth":583,"text":5272},{"id":5888,"depth":566,"text":5891},"content:1.posts:20.sqlclient-active-directory-authent.md","1.posts/20.sqlclient-active-directory-authent.md",1716749600719]