I'm getting a bit lost in what's the proper way to auth to TSI. There are examples for many libraries and MSAL/ADAL approaches.
My scenario is pretty simple, I have AppService in Azure which is REST WebAPI (.NET Core 3.1 that will be upgraded to .NET 5) that collects the data from TSI.
The code for getting token using Azure.Identity is:
What I am not sure of is how should I refresh the token correctly. Is the manual call to GetToken when the current one expires is the proper way when using Managed Identity to access TSI? Or is there any fancier way, maybe I shouldn't use Azure.Identity but something else? Thanks for any suggestions.
My solution based on example AutoRest code for Gen2:
Default code:
Renew token:
I've added the TokenExpiresOn property to TimeSeriesInsightsClient class and also update the value when new token is assigned.
I have no idea if that's the best approach but it works.
I'm getting a bit lost in what's the proper way to auth to TSI. There are examples for many libraries and MSAL/ADAL approaches. My scenario is pretty simple, I have AppService in Azure which is REST WebAPI (.NET Core 3.1 that will be upgraded to .NET 5) that collects the data from TSI. The code for getting token using Azure.Identity is:
What I am not sure of is how should I refresh the token correctly. Is the manual call to GetToken when the current one expires is the proper way when using Managed Identity to access TSI? Or is there any fancier way, maybe I shouldn't use Azure.Identity but something else? Thanks for any suggestions.
My solution based on example AutoRest code for Gen2: Default code:
Renew token:
I've added the TokenExpiresOn property to TimeSeriesInsightsClient class and also update the value when new token is assigned.
I have no idea if that's the best approach but it works.