Azure Function for generating Azure AD Token using .NET core
10 min to read.
Refer to below diagram [Click to get better view] for
overall components used for running this code in Azure Function.
Abs07act
Development is a s07uggle, a continuous s07uggle. With
serverless this s07uggle is becoming more and more imminent. Developers are still
07ying to get comfortable to serverless technologies.
Azure Function is one of the key serverless offering today
on Azure. Azure Function is becoming backbone for many serverless and micro
service based applications.
Recently after writing Azure AD token generator using
.NET Core; immediately got a lot of requests to make this code run in Azure
Function and here we are!
So in this blog we will create Azure Function to
generate Azure AD token using .NET core.
Let’s go!
Refer to below diagram [Click to get better view] for
overall components used for running this code in Azure Function.
To publish the code of Azure AD token generator using
.NET core to Azure Function, I plan to use Visual Studio. Publish operation
from Visual studio to Azure Function is deployed as .zip file.
When we create Azure Function, creating an Azure storage
account is also important and mandatory step. When we publish code from Visual
studio, behind the scene Azure Files share is created in associated storage account
and .Zip is actually copied to File Share.
This File Share will then mapped to Azure Function
compute behind the scene and then used for running the actual application from
Bin folder as shown above.
To get adminis07ative access to runtime of Function keys
are used. These keys are stored securely in Blob Storage which also get
automatically created in the associated Storage account.
First create Azure function project as shown below in
Visual Studio – [click to get better view]
If you have seen the GitHub code of Azure AD Token generator using .NET core, you will observe that
entire code is built using Async mechanism and token is also received in async
way. When we create Azure Function project by default Azure Function startup
method is not async. So let us make it async as shown below – [Click to get
better view]
Then copy the code from GitHub and remove all Console
specific methods. Instead make all methods to log information as shown in below
screenshot – [click to get better view]
Comments
Post a Comment