Code Monkey home page Code Monkey logo

exoazurefunction's Introduction

EXOAzureFunction

Sample Timer Trigger Azure function using the Exchange Online V2 PowerShell module and unattended authentiction.

EXOFunction.ps1 is a example code for using unattended authentication with the Exchange Online V2 module in an Azure function.

Azure Function App Requirements

This is example requires that PowerShell 7 is selected as the Runtime for the Azure Function

Authentication Requirements

This example leverages an App Registration that has been configured to use a certificate for Authentication. A great way to generate this certificate is using an Azure Key Vault - https://docs.microsoft.com/en-us/azure/key-vault/certificates/certificate-scenarios. The certificate can be self-signed.

Key Vault certificates can be imported directly into the app service for your Azure Function:

ImportCertificate.png

The public key for the certificate can be downloaded as a .cer file to be used in an Azure AD App Registration. The complete steps for configuring the Service Principal can be found here: https://docs.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps

Azure Function App Configuration

Several configuration items must be added to your Azure Function configuration to ensure the function will have access to required information. The following items need to be added:

WEBSITE_LOAD_CERTIFICATES : The value of this item is the Thumbprint of the certifacte that was imported into the App Service.
AuthCertThumbprint : This should be the thumbprint value for the certificate that will authenticate to Exchange Online (In almost all cases will the same value as WEBSITE_LOAD_CERTIFICATES)
ClientID : The value of this item is the ClientID/Application ID from your Azure AD App Registration
TenantName : The value of this item is the *.onmicrosoft.com domain for your tenant

Add Exchange Online Management Module to Function

Dependancy Management can be used to ensure the Exchange Online Management module is available to your function. This can be done by adding the Preview version of the module using the requirements.psd1 file. More information can be found here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell?tabs=portal#dependency-management

Here is an example requirements.psd1 file:

@{
    'ExchangeOnlineManagement' = '2.0.4-Preview2'
}

exoazurefunction's People

Contributors

sgreenlee11 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.