Rename an Azure Function - azure

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

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.

Now (2017.10) we can use console to rename the Azure Function name
Open the Console from your Function APP -> Platform features:
Rename the Function folder using command line:
Restart the Function:
Refresh

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.

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

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.

Related

how do I fix HTTP Error 401.3 - Unauthorized?

So I've come across a problem, what I am trying to do is "Check if the python file is ready to execute" as verbatim by my CS professor. So here I what I have done so far:
-Enabled Directory Browsing
-Added a new Script Map
-Linked the executable to the python executable of my python project
-Changed its directory to a new folder (as instructed)
-Created a New Python File with this code in it:
print("Content-Tytpe: text/html\n");
number1 = 1
while number < 10:
print("Hello Python World! <br>");
number = number+1
-and finally clicked on "Browse .80"
I clicked on "test.py" (the python file) and this showed up:
I researched a couple of fixes in this site and among others and this is what I have tried:
-Checked the permissions in the folder and made added a new permission for Everyone with Full Control Access
-Checked Authentication and Anonymous Authentication and set it to Application Pool Identity, both on the Desktop and the Default Website
-I even went to go as far as resetting my PC to check if some other third party application is affecting it
I am really at the end of my rope here so any help would be greatly appreciated.
Try to refer to the steps below.
In IIS, select your site -> Double click on Authentication -> Select Anonymous authentication-> Right-click on it and select Edit option.
Select a Specific user option. Set IUSR, click OK.
Go to the site folder-> open its properties-> go to Security tab-> Make sure IIS_USRS has Read & execute, List folder contents, Read permissions.
After that try to visit the page again.
If the issue persists, try to check whether you are able to visit any HTML file in that folder or not.

Why does triggering Azure Function from Logic Apps return "Bad Request"

My Azure Function works well if run from the browser
https://examplefunction.azurewebsites.net/api/HttpTrigger-Java?name=testEUR.txt&code=mycode
I configured the function to run as a stage in "Logic Apps" - hard-coding the "name" parameter for testing purposes
But then I get "Bad Request" when running the function via logic apps
This can be solved by adding "authlevel":"anonymous" to function.json which is in under site/wwwroot/examplefunction
Instructions to set the authentication level are as follows
select Platform features. Under Development tools, select Advanced tools (Kudu).
On the Kudu website's title bar, from the Debug Console menu, select CMD.
After the next page appears, from the folder list, select site > wwwroot > examplefunction.
Open the function.json file for editing.
In the bindings object, check whether the authLevel property exists. If the property exists, set the property value to anonymous. Otherwise, add that property and set the value.
Once this has been done, then in the Request body of the logic app, just putting "testEUR.txt" works
Obviously, a better answer would be one that does not seem to apparently disable authentication.

Azure function published but not running, "no data available"

I can publish a Azure function from Visual Studio without an error.
This funtion is set to run every 4 seconds ("*/4 * * * * *") but it is not running at all. Even if I try to run it manually it do not run and show the following error:
Status: 404 Not FoundThe resource you are looking for has been
removed, had its name changed, or is temporarily unavailable.
Under monitoring it do not shows data, under success or error count it says no data available :(
Nothing is working please help
This is a pretty old thread but in case anyone is facing the same issue after migrating their Function App to .NET Core 3.1, check that you have also updated the Function Runtime Version to 3. Update the Function App SDK and in Azure portal check that the function runtime settings is 3. Without updating this setting the same 404 error appears whenever you try to call your function app.
For changing the Function Runtime Version open the Function App in Azure Portal then go to Configuration -> Function runtime settings. From the Runtime version dropdown choose ~3.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
According to your 404 error message, it means your function source couldn’t be found. Such as wrong resource path , function name has been changed, wrong function name or the function has been deleted.You could check whether your class name and FunctionName attribute name are consistant. If you have changed code, remeber to rebuild the project.
And please make sure you could run the Azure function successfully in Visual studio before published to Azure. In debug mode, check whether output logs are correct.
Under monitoring it do not shows data, under success or error count it says no data available
This info usually means function has never been triggered before. If you create a new function in Azure and click Monitor directly, you could also see this info. To solve this problem, unless you could trigger this Azure function successfully.
In my case I was deploying the azure function using the Azure Resource Manager (ARM) template. I created it manually and was missing some of the properties for the storage account:
For anyone deploying an Azure Function using an ARM template, I would highly recommend taking a template from the GitHub quickstart ARM templates: https://github.com/Azure/azure-quickstart-templates
It provides the minimum template to get your function (and other resource) up and running.
The issue with your function was that GetFTPData.cs is not a valid function name. VS build doesn't validate the function name and the portal isn't displaying these errors.
This issue is tracking the portal error display https://github.com/Azure/azure-functions-ux/issues/2316
and this is for VS build to validate functionName attribute https://github.com/Azure/azure-functions-vs-build-sdk/issues/174

Error on folder delete in Azure Portal Console

I'm attempting to manually delete a folder in my app service in Azure Portal's console. The console I'm talking about is in the portal, go to App Services > (name) > Deployment slots > (slot) > Console.
(Deploy failed to delete folder, fix is to manually delete and re-run.)
When I attempt to delete the folder, I get this:
Basically, I enter the command to delete the folder, get an "are you sure, enter Y/N", I type Y and return, and then get an error about 'Y' is not recognized as an internal or external command. Just hitting return, not entering Y, I just get a new prompt line.
What am I missing here?
OH MY GOSH this is the stupidest thing.
Still don't know what's up with the delete in the Portal Console, but if you go to the KUDU console, it works just fine.
https://{your application}-{slot}.scm.azurewebsites.net/DebugConsole

Reading a configuration file from azure function with precompiled assembly

I've an Azure Function that should read data from a file called schema.config
I've uploaded it on the portal as shown here
In my application I do
public static string GetSchemaFile()
{
string file = ConfigurationManager.AppSettings.Get("schemafile");
FileInfo fi = new FileInfo(file);
return fi.FullName;
}
And I've defined an application setting on Azure as
When I run the code I got this exception
Exception while executing function: Functions.blobfunction
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.blobfunction ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.IO.DirectoryNotFoundException : Could not find a part of the path 'D:\Windows\system32\bin\schema.json'.
So it seems that it looks in D:\Windows\System32 as working folder...
How do I tell to look the file in the "bin" folder?
If you go to the Kudu console you can see your exact folder structure. Here's how to do that:
Click on your function app root node in Azure Portal (the one right below where it says "Function Apps" in the top left)
Click on "Platform Features" at the top
Click on "Advanced Tools (Kudu)" under "Development Tools" on the left hand side, this opens a new window/tab
Select CMD at the top under "Debug Console"
Navigate to site/wwwroot and you'll see all your projects
Select your project then the bin directory
The actual full path will then be displayed in the bottom part of the window, you can use that instead.
You may want to consider renaming the folder to something other than bin, traditionally that's where you put executable files.

Resources