This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using AzureFunctionsDependencyInjection.Services; | |
using Microsoft.Azure.Functions.Extensions.DependencyInjection; | |
using Microsoft.Extensions.DependencyInjection; | |
// Required if you want to add custom services | |
[assembly: FunctionsStartup(typeof(AzureFunctionsDependencyInjection.Startup))] | |
namespace AzureFunctionsDependencyInjection | |
{ | |
public class Startup : FunctionsStartup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Claims; | |
using AzureFunctionsDependencyInjection.Services; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Logging; | |
using Newtonsoft.Json; | |
using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
namespace AzureFunctionsDependencyInjection.Services | |
{ | |
public class DataService : IDataService | |
{ | |
private readonly IBlobService _blobCache; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Blob; | |
namespace AzureFunctionsDependencyInjection.Services | |
{ | |
public class BlobService : IBlobService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Logging; | |
namespace AzureFunctionsDependencyInjection | |
{ | |
public class Warmup | |
{ | |
private readonly IConfiguration _configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using AzureFunctionsDependencyInjection.Services; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Extensions.Logging; | |
namespace AzureFunctionsDependencyInjection | |
{ | |
public class CacheRefresh | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace with your managed identity object ID | |
$miObjectID = "17707c90-dab4-483d-a57f-65e91ac3d94f" | |
# The app ID of the API where you want to assign the permissions | |
$appId = "00000003-0000-0000-c000-000000000000" | |
# The app IDs of the Microsoft APIs are the same in all tenants: | |
# Microsoft Graph: 00000003-0000-0000-c000-000000000000 | |
# SharePoint Online: 00000003-0000-0ff1-ce00-000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace with your managed identity object ID | |
$miObjectID = "17707c90-dab4-483d-a57f-65e91ac3d94f" | |
# The app ID of the API where you want to assign the permissions | |
$appId = "00000003-0000-0000-c000-000000000000" | |
# The app IDs of the Microsoft APIs are the same in all tenants: | |
# Microsoft Graph: 00000003-0000-0000-c000-000000000000 | |
# SharePoint Online: 00000003-0000-0ff1-ce00-000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace with your managed identity object ID | |
$miObjectID = "17707c90-dab4-483d-a57f-65e91ac3d94f" | |
# The app ID of the API where you want to assign the permissions | |
$appId = "00000003-0000-0000-c000-000000000000" | |
# The app IDs of the Microsoft APIs are the same in all tenants: | |
# Microsoft Graph: 00000003-0000-0000-c000-000000000000 | |
# SharePoint Online: 00000003-0000-0ff1-ce00-000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Azure.Identity; | |
public async Task<string> GetAccessTokenAsync(string resourceUrl) | |
{ | |
var credential = new DefaultAzureCredential(); // Or new ManagedIdentityCredential(); | |
var accessToken = await credential.GetTokenAsync(new TokenRequestContext(scopes: [resourceUrl + "/.default"]) { }); | |
return accessToken.Token; | |
} |
OlderNewer