Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing disabled functionality for azure functions v4 #267

Open
aaarichter opened this issue Jun 3, 2024 · 4 comments
Open

missing disabled functionality for azure functions v4 #267

aaarichter opened this issue Jun 3, 2024 · 4 comments

Comments

@aaarichter
Copy link

Investigative information

Please provide the following:

  • Timestamp: 0
  • Function App name:
  • Function name(s) (as appropriate):
  • Invocation ID: e5d5ee04-d5e8-4c03-8d8e-4c13067b0574
  • Region: Germany West Central

Repro steps

Provide the steps required to reproduce the problem:

  1. I created a v4 HTTP Azure function for manually triggering the code that I normally run in a weekly cron job Azure function
  2. I want to disable this Azure function by default, as it was possible in v3
  3. I deploy the Azure function via Terraform

Expected behavior

On deployment via Terraform, the HTTP functions should be enabled by default, but disabled when set via code

Actual behavior

Upon deployment, the Azure Functions are all enabled by default

Known workarounds

Related information

Provide any related information

  • Programming language used - Javascript / Typescript
  • Links to source
  • Bindings used
Source
import { app } from '@azure/functions';
import { sevenpaceImporter } from '../sevenpaceImporter';

app.http('httpImportFrom7PaceApi', {
  methods: ['GET'],
  authLevel: 'anonymous',
  handler: (_req, context) => sevenpaceImporter(context),
});
@ejizba
Copy link
Contributor

ejizba commented Jun 3, 2024

I want to disable this Azure function by default, as it was possible in v3

Hi, can you expand on how you did this with v3?

@aaarichter
Copy link
Author

aaarichter commented Jun 4, 2024

I found this solution https://learn.microsoft.com/en-us/azure/azure-functions/disable-function?tabs=portal which shows various ways to disable them.

In the v3 programming model, you could set the disabled: false property in the function.json. With most of the function.json configuration being set in the trigger handlers, it feels strange not to have this option available (or do I remember this wrong?) . Apparently, I need to use environment settings.

@ejizba
Copy link
Contributor

ejizba commented Jun 4, 2024

Yeah environment variables should work. You can also wrap your function registration in an if cases directly in your code. One potential downside of this is that functions won't be listed at all when they're disabled this way.

let disabled = true;
if (disabled) {
    app.http('httpTrigger1', <any>{
        methods: ['GET', 'POST'],
        authLevel: 'anonymous',
        handler: httpTrigger1
    });
}

We could potentially add a "disabled" flag when registering a function. This is not something that's supported yet, but let us know if you would like it:

app.http('httpTrigger1', {
    methods: ['GET', 'POST'],
    authLevel: 'anonymous',
    disabled: true,
    handler: httpTrigger1
});

@ejizba ejizba added the feature label Jun 21, 2024
@ejizba ejizba added this to the Backlog Candidates milestone Jun 21, 2024
@ejizba ejizba added the P2 label Jun 21, 2024
@Sarabadu
Copy link

Sarabadu commented Oct 8, 2024

the issue with environment variables is that http-trigger1 is a valid function name but does not generate a valid environment variable name when using that button, should the name of the function be limited to work well in the azure portal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants