Skip to content

Push-OutputBinding Should Throw Exceptions at Script Scope #284

Open
@JustinGrote

Description

@JustinGrote

Tried pushing an output binding to a table today, and it errored with the following:

7/19/2019 7:05:13 PM] Executed 'Functions.SendGrid' (Failed, Id=f7995877-67db-4af4-80dc-6a9390a35bba)
[7/19/2019 7:05:13 PM] System.Private.CoreLib: Exception while executing function: Functions.SendGrid. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. Microsoft.Azure.WebJobs.Extensions.Storage: 0:The specified entity already exists.
RequestId:c1db00fc-0588-48c8-a395-7a45739ff0cf
Time:2019-07-19T19:05:13.3671345Z (HTTP status code 409: EntityAlreadyExists. 0:The specified entity already exists.
RequestId:c1db00fc-0588-48c8-a395-7a45739ff0cf
Time:2019-07-19T19:05:13.3671345Z). Microsoft.WindowsAzure.Storage: 0:The specified entity already exists.
RequestId:c1db00fc-0588-48c8-a395-7a45739ff0cf
Time:2019-07-19T19:05:13.3671345Z.

Unfortunately I can't try/catch or trap{} it, so my script just dies. As a workaround I just fetch a table object directly, but I shouldn't have to, I should be able to follow the output binding pattern and practice, but be able to handle any issues that might crop up.

#Get an Azure Table
#Adapted from https://docs.microsoft.com/en-us/azure/cosmos-db/tutorial-develop-table-dotnet
using namespace Microsoft.Azure.Cosmos.Table
function Get-AzFunctionTable ([String]$FunctionTableName = $TriggerMetaData.FunctionName) {
    #requires -module Az.Storage
    $FunctionStorageAccount = [CloudStorageAccount]::Parse($env:AzureWebJobsStorage)
    $FunctionTableClient = [CloudStorageAccountExtensions]::CreateCloudTableClient($FunctionStorageAccount)
    $FunctionTable = $FunctionTableClient.GetTableReference($FunctionTableName)
    if ($FunctionTable.CreateIfNotExists()) {Write-Output "Table $($functiontableclient.baseuri)/$($FunctionTableName) did not exist so it was created."}
    if ($FunctionTable) {
        return $FunctionTable
    } else {
        write-error "There was a problem fetching the Azure Function Table"
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions