0

I have created a functions app and then created a function, The function name defaulted to TriggerCSharp1 or similar.

After adding code I was wondering how to change the function name so I tried Ftp'ing into the functions app and manually changed the folder name TriggerCSharp1. I went back to the Azure portal and now when I click on the function app I get an error The access token is invalid. and nothing appears beneath, see screen-shot below.

enter image description here

I am not sure how I can delete this function app now since I can't get in its blade. The only way I can think of now is to delete the resource group that contains this function app but that is not something I can do since I have tons of other resources in there too.

Alaa Masoud
  • 7,085
  • 3
  • 39
  • 57

3 Answers3

1

Edit: As suggested by David, resources.azure.com is easier and requires no client bits.


Solved using Azure-CLI with the command azure site delete <site name>

Alaa Masoud
  • 7,085
  • 3
  • 39
  • 57
  • 8
    For future reference, you can also use https://resources.azure.com/, which is a bit easier than CLI and requires no client bits. – David Ebbo Aug 17 '16 at 22:00
  • I think the above comment from David Ebbo should be an answer of its own - it works and also opens up a lot of other opportunities. – bevada Oct 18 '16 at 06:29
1

One function app may contain multiple functions and hence deleting the whole function app if only one function is corrupted may be overkill. For those in this situation deleting the function folder in the Kudu console/using powershell is a better way.

USING KUDU CONSOLE

  1. Go to https://<yourFunctionApp>.scm.azurewebsites.net
  2. Click on DEBUG(top bar) -> CMD and in the new page that appears navigate to site -> wwwroot
  3. Find your function there and delete it (click on the icon to the right of the Edit/pencil icon)

USING POWERSHELL (based on this)

    $username = '<publish username>' #IMPORTANT: use single quotes as username may contain $
    $password = "<publish password>"
    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
    $commandBody = @{
        command = "rm -d -r myAzureFunction"
        dir = "site\\wwwroot" 
    }
    $deleteUrl = "https://<myFunctionApp>.scm.azurewebsites.net/api/command"
    Invoke-RestMethod -Uri $deleteUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST `
    -ContentType "application/json" -Body (ConvertTo-Json $commandBody) 

The publish username and publish password can be obtained as detailed here

    $creds = Invoke-AzureRmResourceAction -ResourceGroupName YourResourceGroup -ResourceType Microsoft.Web/sites/config -ResourceName YourWebApp/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force

    $username = $creds.Properties.PublishingUserName
    $password = $creds.Properties.PublishingPassword
S Raghav
  • 1,386
  • 1
  • 16
  • 26
  • What "language" is the command "rm -d -r myAzureFunction" ? If I run the CMD or powershell debug console (https://mineStuff.scm.azurewebsites.net/DebugConsole) the rm command does not work/exist. (so I can't test anything) I'm actually trying to get rid of EVERYTHING under "site\wwwroot" with (hopefully) one execution. – granadaCoder Nov 10 '17 at 21:11
  • I found $commandBody = @{ command = "del /S /F /Q .\\" dir = "site\\wwwroot" } at https://json.codes/blog/deploying-to-azure-using-kudu/ this removes files, but not directories...... if anyone has a remove all files/subfolders recursively, please post here. (with a single "Invoke-RestMethod" call .. ) ! – granadaCoder Nov 10 '17 at 21:51
  • @granadaCoder the -r switch in the rm command should delete directories recursively. You can check this out using the Powershell debug console. The "language" is the one usually used in linux commandline, but powershell has support for that. Can you refresh the page after running the command to confirm that the folder is deleted? It works for me – S Raghav Nov 13 '17 at 10:21
0

If you wanted to do this in PowerShell, something like the following should work ...

Login-AzureRmAccount  #Enter your username / pw
$funcApp = Get-AzureRmWebApp -Name "Your Function App Name"
Remove-AzureRmWebApp -WebApp $funcApp

If you have more than one subscription then make sure your using the right one. You could also add a -Confirm:$true to the remove command if you didn't want the check prompt.

JJones
  • 795
  • 6
  • 12