Cannot delete Azure Function dll from wwwroot/bin folder - azure

I am using kudu console to redeploy my azure function actifacts, however when i try to delete old artifacts bin folder is failed to delete, i get 409 Conflict: Canot delete directory, it is either not empty or access is not allowed.
When i try to delete the function dll failed with 404 not found error as shown below. I cannot find any handle with function dll.
I have no APP Setting configured for WEBSITE_RUN_FROM_PACKAGE. Any idea why this behaviour and how to delete old artifacts and re-deploy new function artifacts?
Update
I have toggled WEBSITE_RUN_FROM_PACKAGEV 0 to 1 and switched back to 1 to 0. Now i able able to delete the bin folder, looks like there is a process still using my function application dll but can not be found in process explorer. When function runtime is restarted the resource is released very weird!

The reason for the WEBSITE_RUN_FROM_PACKAGE setting is that vs2019 is used for release, and vs2019 is released, which uses zip deploy.
Now if you want to modify or delete the file, the only way to do it is to set WEBSITE_RUN_FROM_PACKAGE = 0 and then modify it. In the current version of the function app, after modifying WEBSITE_RUN_FROM_PACKAGE = 0, all the contents in the wwwroot folder will be deleted.
(after testing, the function app created after April 1st and 2nd will have this phenomenon. Contact a Microsoft engineer to confirm This is normal expected behavior.)
If you want to modify the file, it is not recommended to use vs2019 to publish directly. It is recommended to use the command line to publish. Because of this you can read and write files under wwwroot.
func azure functionapp publish function_app_name --csharp --nozip --force
For more details, you can refer my answer in below post.
How to change content dynamically after function is called in Azure function app

Related

The Publish URL https://waws-prod-am2-xxx.publish.azurewebsites.windows.net/ is unreachable

I created a function app on Azure Portal with below configuration.
And I created a simple HTTP trigger Function App on VS 2019 version of 16.7.6. The function is working successfuly on local machine. When I want to publish it to Azure, it returns below error;
Publish has encountered an error. The Publish URL
https://waws-prod-am2-xxx.publish.azurewebsites.windows.net/ is
unreachable. The application may be stopped, restarting or
unavailable. Try again once the publish target is available.
The publishing summary is;
When I check the publish profile on VS (.pubxml file), I see the line
<PublishUrl>https://waws-prod-am2-311.publish.azurewebsites.windows.net/</PublishUrl>
But it should be
<PublishUrl>http://myfuncappdss.scm.azurewebsites.net</PublishUrl>
I change it manually and there is any other error that is not detected
Publish has encountered an error. Publish has encountered an error. We
were unable to determine the cause of the error.
It hasn't published for 2 days. Before, I published successfully. I search it on google but I couldn't find any clue.
Btw, I can reach the FTP file of the function successfully. And the function running successfully on https://myfuncappdss.azurewebsites.net/ site.
I tried it with az command also but it wasn't work, too. All my teammates can't publish also. So, the problem is not just about my computer.
Why is the PublishUrl set with wrong URL?
When I check the publish profile in Visual Studio (.pubxml file), I see the line:
<PublishUrl>https://waws-prod-am2-311.publish.azurewebsites.windows.net/</PublishUrl>
But it should be
<PublishUrl>https://myfuncappdss.scm.azurewebsites.net</PublishUrl>
I changed it manually and then it started working fine.
Step 1: Do the above URL changes and save the .pubxml file
Step 2: Close Visual Studio.
Step 3: Open your project in Visual Studio.
Step 4: Now publish, it should work as expected…
Here we have successfully deployed the Function App.
Update:
Thanks for Aybuke's aharing, this is the reason of the problem:
The problem base is about function publish profile. When I follow the steps, (Go to Azure Portal-->Go to function app-->Overview menu-->Get Publish Profile) I can download the publish profile of function. So, I can see the publish settings of function. "publishUrl="https://waws-prod-am2-xxx.publish.azurewebsites.windows.net:443"" This line is in the publish profile file that I downloaded. But it should be "publishUrl="https://myfuncappdss.scm.azurewebsites.net"". That is why the published zip file is sent to wrong url. So, there are some problems while creating function on Azure Portal.
Original Answer:
Did you encounter this error?
I notice you change publish url to http://myfuncappdss.scm.azurewebsites.net, please change it to https://myfuncappdss.scm.azurewebsites.net and try again.
If I use http, I also can not publish my function app. I don't know why the publish url is not what you want, but the az command should work. Any details when you use az command?
Change http to https, it should work.
I had this issue and the problem was on the App Function Settings.
In Networking, Inbound Traffic had Access Restrictions ON.
I had to add my public IP Address and then I was able to publish.

How to edit Azure function code on Azure portal once the parameter WEBSITE_RUN_FROM_PACKAGE as been set to 1?

I know this is not possible because of the parameter described in this message:
Your app is currently in read only mode because you are running from a package file. To make any changes update the content in your zip file and WEBSITE_RUN_FROM_PACKAGE app setting.
However, if I change the value of this parameter to 0, the code is still uneditable.
My Azure function is using a lot of libraries that I have to deploy everytime I update even a single character in the code.
This is really anoying. I would like to be able to edit my code without wasting 5 ou 10 minutes waiting for all libraries to be downloaded too.
Do I need to remake my Azure function and edit it only on Azure portal to keep the possibility to edit it ?
Is there a way to get the code back to editable status ?
Thank you.
The thing you need to do is to delete the WEBSITE_RUN_FROM_PACKAGE.
I noticed that when we deployed a Function app from local to azure, the app setting WEBSITE_RUN_FROM_PACKAGE would be added by default, which means your code file is in read-only mode, you can not edit it unless you delete the WEBSITE_RUN_FROM_PACKAGE.
But it should work if you change the value to 0, because it works for me. That's weird.
MIcrosoft docs, Run your functions from a package file in Azure, states the valid values for WEBSITE_RUN_FROM_PACKAGE are either 1 or <URL>, not 0. So rather than setting the value to 0, delete the WEBSITE_RUN_FROM_PACKAGE setting completely.

What is the best way to move an online Azure Function to a local git repository?

I have written an Azure Function App by using the User Interface of Azure Portal. The code is written in C#.
Now, I want to:
download all of the relevant code and configuration files of this
function app
Create an IDE project (e.g. IntelliJ, Visual Studio Code, ...)
store it in a git repository
Deploy the code from IDE or command line to Azure and thereby replacing the previously written Azure function.
So far, I have found only documentation on how to initiate Azure function projects with no previous code. Does somebody know how to do above?
Yes, you could go to your function Overview page, click on Download app content as shown below.
And in your situation, you want configuration files, so select the Content and Visual Studio Project and Include app settings in the download. What is app settings? This will include a local.settings.json file which contains your application settings.
Also the third party .dlls are included.
In the VS, select the folder and it will be working.
Update:
Open the function with vs, then just right click the function and choose Publish, it will show you the publish page. Click start, then you will be able to publish it to a existing Function.
Follow this Setting up a CI/CD pipeline for Azure Functions doc which explain each step in detail.

Functions published as a VS2015 Web Application not showing up in the portal list

I followed the roadmap to create a set of Azure Functions as a Web Application. They deployed without an issue to my Azure Function App.
I moved the project to a new solution and changed the name spaces and updated the function.json files. When I redeployed to the Function App I was getting a bad entry point on one function which I double checked and tried to update a couple of ways without any success.
Thinking that the Function App might be caching I tried restarting the app and then finally went into the App Service Editor and deleted all the files and republished. Now none of the functions show up in the list even through the directories and function.json files for each function are confirmed present.
Has anyone else experienced something like this or have a suggestion as to how to resolve it?
It looks like your script file in function.json is set to a dll that doesn't exist in bin. Double check the dll name there.
You can see the content of bin folder on azure through debug console by going to https://<yourAppName>.scm.azurewebsites.net/DebugConsole

How do I get a web job to use the azure portal storage connection string, not what's in the web job console app's deployed config file?

I've created a web job using the webjobs sdk that is linked to my web application. Well it isn't anymore (I removed the webjobs-list.json file from the web app project), because when it was linked, it just copied the source code files into the websites' app-data folder, not the bin folder/binaries/exe. But now that my web job is deployed from visual studio online to azure with my website, and tries to run, it's not reading the connection strings (AzureWebJobsStorage and AzureWebJobsDashboard) from the connection strings in my web application's settings in the azure portal. It looks for them in the config file that is deployed with the exe that is generated from compiling the webjob. If I manually put those strings in that config and check in, and redploy it will use them from there, so it's not checking the portal at all (even though my web app is running fine using what is defined in the portal). I thought that all web jobs were supposed to look for connection strings in the azure portal first? That isn't happening at all for me. Has anyone else experienced this? Could it have something to do with how it's deployed by visual studio online?
Part of the error getting logged for the webjob process when trying to start:
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException: Error indexing method 'Functions.ProcessTestQueueMessage' ---> System.InvalidOperationException: Microsoft Azure WebJobs SDK 'Storage' connection string is missing or empty. The Microsoft Azure Storage account connection string can be set in the following ways:
[04/01/2017 02:27:40 > ceef22: INFO] 1. Set the connection string named 'AzureWebJobsStorage' in the connectionStrings section of the .config file in the following format , or
[04/01/2017 02:27:40 > ceef22: INFO] 2. Set the environment variable named 'AzureWebJobsStorage', or
[04/01/2017 02:27:40 > ceef22: INFO] 3. Set corresponding property of JobHostConfiguration.
[04/01/2017 02:27:40 > ceef22: INFO] at Microsoft.Azure.WebJobs.Host.Executors.StorageAccountParser.ParseAccount(String connectionString, String connectionStringName, IServiceProvider services)
Also, the only way I could get this to really deploy was to remove the webjobs-list.json file from the properties folder in the web project. I know I'm not supposed to do that, that everything should just work and deploy with that in there, but when I left it in there, it wouldn't copy the binaries/bin/executable files into the App_Data\Jobs\continuous[webjob] folder on the website...it would literally copy all of the source code\files for the web job project into there (which of course wouldn't work/run, since it's just code, not an exe). After removing that webjobs-list.json file, and then adding a second task to my release to find the [webjob].zip file from the build, then it would copy just the binaries and executable into the App_Data\Jobs\continuous[webjob] folder. Maybe this is just an issue with trying to build and release from visual studio online, and it doesn't handle web job deployment well...not sure, I haven't been able to find a lot of information on setting that up to deploy a web job with a web app.
Normally, this should just work. The flow is:
The WebJobs exe doesn't run in-place, but first gets copied to a temp folder
As part of that copying process, if any of the AppSettings & Conn Strings in the foo.exe.config file are set as Azure settings, they get replaced (only in the temp copy, not under App_Data).
Can you make sure that you are deploying both your foo.exe and foo.exe.config?
Update: as we found on chat, the problem was that you had a typo in the name of the connection string in Azure.

Resources