Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
95 stars 64 forks source link

Enabling the Disable(Type) attribute overload #515

Closed FlavioGarciaDev closed 3 years ago

FlavioGarciaDev commented 3 years ago

This validation was outdated. Tested locally using Microsoft.NET.Sdk.Functions (3.0.2) and Microsoft.Azure.WebJobs (3.0.22).

[Disable(typeof(ValidadorDisable))]
[FunctionName(FunctionName)]
public async Task Run([TimerTrigger(CronJob)] TimerInfo timer, ILogger log)
{
    throw new NotImplementedException();
}

Retrieving my boolean disabled settings from a config file using the Type overload:

public class ValidadorDisable
  {
      public bool IsDisabled(MethodInfo method)
      {
          var functionName = method.GetCustomAttributes(true).OfType<FunctionNameAttribute>().FirstOrDefault().Name;
          return Configuration.Get.FunctionConfiguration.DisabledFunctions[functionName];
      }
  }