Noralogix / genesys-azure-webjobs-sdk

Framework that simplifies the task of writing code that runs in Azure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Genesys.Azure.WebJobs.Extensions .NET NuGet version Nuget downloads

Framework that simplifies the task of writing code that runs in Azure.

Install-Package Genesys.Azure.WebJobs.Extensions

With the help of the binding attribute [Genesys], you can simplify generation of the access token and keep it in the Azure Storage until expired. After that you can use this token in the Genesys API. Authorization based on client credentials specified in the Azure App Function config. Library namespace

using Genesys.Azure.WebJobs.Extensions;

Azure Function with binding attribute [Genesys]

namespace SampleFunctionApp
{
    public static class GetGenesysOrg
    {
        [FunctionName("GetGenesysOrg")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "org")] HttpRequest req
            , [Genesys] IGenesysAccessToken token
            , ILogger log)
        {
            Organization org = await GetOrgAsync(token.Value, token.Environment);
            return new OkObjectResult(org);
        }
        ...
    }
}

Azure Function Config file. GenesysOrgId For Azure Token Table partition key, otherwise partition key value will be empty string.

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "GenesysClientId": "",
    "GenesysClientSecret": "",
    "GenesysEnvironment": "mypurecloud.ie",
    "GenesysOrgId": ""
  }
}

GenesysAtribute properies

  • Connection Optional. Azure storage account to use. Default connect AzureWebJobsStorage.
  • TokenTable Optional. Azure Table name, where tokens will be cached. Default table name GenesysTokens.
  • ClientId Optional. The App setting name that contains the Genesys ClientId value. Default name GenesysClientId.
  • ClientSecret Optional. The app setting name that contains the Genesys ClientSecret value. Default name - GenesysClientSecret.
  • Environment Optional. The app setting name that contains the Genesys Environment value. Default name GenesysEnvironment.

Also you can specify your custom GenesysTokenProvider with GenesysAttributeCustomConfigProvider

using Genesys.Azure.WebJobs.Extensions;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection;

[assembly: WebJobsStartup(typeof(SampleFunctionApp.Startup))]
namespace SampleFunctionApp
{
    internal class Startup : IWebJobsStartup
    {
        public void Configure(IWebJobsBuilder builder)
        {
            builder.Services.AddSingleton<GenesysTokenProvider>();            
        }
    }
}

About

Framework that simplifies the task of writing code that runs in Azure.

License:MIT License


Languages

Language:C# 100.0%