Azure Function: How to disable a specific ENDPOINT via C#

Azure Function: How to disable via C#

Yesterday I needed to stop a specific endpoint of my Azure Functions. We can do this operation in many different ways. In this post I show how to implement via C#.

I copy and paste the Azure function code from my previous “italian” post Azure Function: Trigger al caricamento su Blob Storage and I change the code with a new attribute.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;

namespace FunctionTest
{
    public static class BlobTriggerTest
    {
        [Disable]
        [FunctionName("BlobTriggerTest")]
        public static void Run(
            [BlobTrigger("samples-workitems/{name}", 
                Connection = "connection-string-setting-name")]Stream myBlob, 
            string name,
            ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n " +
                $"Name:{name} \n" +
                $"Size: {myBlob.Length} Bytes");
        }
    }
}

Can you see the [Disable] attribute in this Endpoint? Now you only release the new code on production!