66

How to rename an Azure Function?

I want to replace a default 'HttpTriggerCSharp1' name to my own. At the moment unfortunately this name is included in the function url and there is no option to change it:

https://functions-xxx.azurewebsites.net/api/HttpTriggerCSharp1

image

Pawel Maga
  • 5,428
  • 3
  • 38
  • 62

5 Answers5

56

The UI does not directly support renaming a Function, but you can work around this using the following manual steps:

  • Stop your Function App. To do this, go under Function app settings / Go To App Service Settings, and click on the Stop button.
  • Go to Kudu Console: Function app settings / Go to Kudu (article about that)
  • In Kudu Console, go to D:\home\site\wwwroot and rename the Function folder to the new name
  • Now go to D:\home\data\Functions\secrets and rename [oldname].json to [newname].json
  • Then go to D:\home\data\Functions\sampledata and rename [oldname].dat to [newname].dat
  • Start your function app, in the same place where you stopped it above In the Functions UI, click the refresh button in the top left corner, and your renamed function should appear
    Note: doing this can lose some historical logging.

Github Issue for renaming Azure Function


Edit for new info

To anyone like myself that arrived here looking to rename their function, despite this being the previously correct answer, there is now a much smoother CMD based process as detailed in this answer by SLdragon and an even smoother GUI based process detailed in this answer by Amerdeep below.

Community
  • 1
  • 1
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • 2
    I want to change function name, not app name. See my updated question. – Pawel Maga Nov 17 '16 at 13:53
  • 1
    Thanks, it helped. All functions are stored in functionsappname/site/wwwroot directory where we can add or remove files and directories. It's not comfortable, but at least possible. – Pawel Maga Nov 17 '16 at 14:05
  • 2
    Yes, this is the only way right now - we have an issue tracking this [here](https://github.com/projectkudu/AzureFunctionsPortal/issues/198) – mathewc Nov 17 '16 at 16:34
  • 4
    See https://github.com/Azure/azure-webjobs-sdk-script/wiki/Renaming-a-Function for more complete manual steps. Issue is tracked by https://github.com/projectkudu/AzureFunctionsPortal/issues/198 – David Ebbo Nov 17 '16 at 17:39
  • 2
    to rename in Kudo, type: rename oldname newname – Minh Nguyen Feb 22 '17 at 14:30
  • Actually for me I had to type ren oldname newname. Rename wasn't a recognised command. – Chris Rae Mar 10 '17 at 22:36
  • I was denied in both the console as well as the Azure portal (with no helpful messages about what the issue was). What did work for me was renaming the folder locally and then re-deploying to Azure. – jbobbins May 22 '20 at 02:01
  • you have to stop the function – 4c74356b41 May 22 '20 at 03:54
  • When your function app is tied with source control [ex Az Devops], this change will not take effect. – Anand Sowmithiran May 31 '23 at 06:48
32

Now (2017.10) we can use console to rename the Azure Function name

  1. Open the Console from your Function APP -> Platform features:

Open the console

  1. Rename the Function folder using command line:

Rename the folder

  1. Restart the Function:

Restart the function

  1. Refresh

Refresh

SLdragon
  • 1,477
  • 16
  • 19
29

Create a new function and you will have an option to name it, then delete the default one(HttpTriggerCSharp1).

I know it's not renaming, but the easiest option around.

enter image description here

Abhijeet Ahuja
  • 5,596
  • 5
  • 42
  • 50
  • 1
    I can't upvote this enough. I can't find the Kudu Console everyone else speaks of. – mellis481 May 04 '17 at 18:50
  • Here are some instructions on how to access the Kudu console: https://blogs.msdn.microsoft.com/benjaminperkins/2014/03/24/using-kudu-with-windows-azure-web-sites/ – zurebe-pieter Jun 06 '17 at 21:47
24

Go to Function Apps Click on platform features Click on app service editor Right click on your default function name-select

Virb
  • 1,639
  • 1
  • 16
  • 25
  • 1
    great quick way of doing this! Thanks! – AndreiC Sep 01 '18 at 18:22
  • 3
    That's the way of renaming today. You get a VS-Code like UI in the browser and can rename the function with a right-click on the name. Refresh in the Portal to see the changes. – jboi Dec 05 '18 at 11:03
  • 4
    Worth mentioning that this solution does not work for Linux apps. – lammy Jun 27 '19 at 12:56
10

Below worked for me.

I wanted to rename my azure function from "HttpTriggerCSharp1" to "my-new-func1"

Go to

Function Apps > 
 My-Function-App > 
  Platform Features TAB > 
   Console >

Run below commands:

cd D:\home\site\wwwroot
move HttpTriggerCSharp1 my-new-func1

Now restart the application:

Function Apps > 
 My-Function-App > 
  Overview TAB > 
   Restart

NOTE: The function 'code' query param changes by doing this.

Manohar Reddy Poreddy
  • 25,399
  • 9
  • 157
  • 140