Skip to content

[QUERY] How do I create a Function v4 using resource manager API? #37919

@yuramag

Description

@yuramag

Library name and version

Azure.ResourceManager.AppService

Query/Question

Consider the following code that worked for function apps prior to v4:

var bindingsConfig = new
{
    bindings = new object[]
        {
            new
            {
                AuthLevel = "function",
                Type = "httpTrigger",
                Direction = "in",
                Name = "request",
                Methods = new[] {"post"}
            },
            new
            {
                Type = "http",
                Direction = "out",
                Name = "$return"
            }
        }
};

app = await myResourceGroup.GetWebSites().GetAsync("my-app-name", ct);
var func = await app.GetSiteFunctions().CreateOrUpdateAsync(WaitUntil.Completed, "my-func-name", new FunctionEnvelopeData
{
    Config = BinaryData.FromObjectAsJson(config)
}, ct);

Now according to this doc, function.json is no longer used in v4 programming model. My question is - does it mean I shouldn't be passing bindingsConfig into CreateOrUpdateAsync()? When I try it though I get the following error:

Azure.RequestFailedException: 'Error creating function. <my-func-name> is not a valid function name
Status: 400 (Bad Request)
ErrorCode: BadRequest

In general how should I call CreateOrUpdateAsync() to create a v4 kind of function?

Environment

No response

Metadata

Metadata

Assignees

Labels

App ServicesMgmtThis issue is related to a management package.Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions