Build with an Azure free account. Get USD200 credit for 30 days and 12 months of free services.

Start free today

Serverless automation using PowerShell in Azure Functions

Sign in to queue

Description

Eamon O'Reilly joins Scott Hanselman to show how PowerShell in Azure Functions makes it possible for you to automate operational tasks and take advantage of the native Azure integration to deliver and maintain services.

Tag:

Azure

Embed

Download

The Discussion

  • User profile image
    Elliot Munro

    Any chance we could get a copy of the script which posts that card to a Teams channel?

  • User profile image
    eamono
    Below is the function to send a teams message. The $env:TeamsWebhook is manually generated for an incoming webhook to the Teams channel. You can get it by right clicking -> connectors -> Incoming Webhook from the Teams channel.
    Thanks,
    Eamon


    param($Request, $TriggerMetadata)

    # Log body of request
    ConvertTo-Json $Request.Body | Write-Verbose

    # Get Teams channel url from application setting
    $channelURL = $env:TeamsWebhook

    if (!([string]::IsNullOrEmpty($ChannelURL)))
    {
    $TargetURL = $Request.Body.data.context.portalLink

    $Body = ConvertTo-Json -Depth 4 @{
    title = "Azure Alert has fired"
    text = "Azure Alert has fired"
    sections = @(
    @{
    activityTitle = "Azure notification has fired"
    activitySubtitle = "Alert on function app " + $Request.Body.data.context.resourceName
    activityText = "This is the detail of the alert..."
    activityImage = "https://www.contoso.image.png"
    }
    )
    potentialAction = @(@{
    '@context' = 'http://schema.org'
    '@type' = 'ViewAction'
    name = 'Click here to manage Function'
    target = @($TargetURL)
    })
    }

    # call Teams webhook
    Invoke-RestMethod -Method "Post" -Uri $ChannelURL -Body $Body | Write-Verbose
    }
  • User profile image
    Bo Allan

    Do you need to have your Azure Subscription whitelisted for this preview?

  • User profile image
    Alex

    Is this pitched to ultimately replace Azure Automation in time?

  • User profile image
    jodoglevy
    Very cool!

Add Your 2 Cents