0

when I am offline and not connected to Azure I cannot seem to debug an Azure function in Visual Studio Code.

What settings can I change in the launch.json to allow me to debug functions without connectivity?

enter image description here

1
  • Is your ` "AzureWebJobsStorage": "UseDevelopmentStorage=true" `? And your storage emulator is running? Commented Feb 10, 2023 at 0:51

1 Answer 1

0

Not Sure if you are using Python or PowerShell Azure Functions as nothing has been mentioned in the Question.
I have been working with both of the languages of Azure Functions in VS Code IDE.

As of now, checked with the latest Version of VS Code, Python Versions (3.9.x, 3.10.x) and PowerShell Azure Functions; they are working successfully in the debug mode.

I found the various causes and resolutions of the debugging process in Azure Functions in VS Code given by the user @HariKrishna, that will helps to fix your issue, refer to the SO #71532944

For PowerShell Azure Function, below is the code I have:

run.ps1:

using  namespace  System.Net
  
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host  "PowerShell HTTP trigger function processed a request."

# Interact with query parameters or the body of the request.
Connect-AzAccount -Tenant '<your_Azure_Tenant_id' -SubscriptionId '<Your-Azure_Subscription_Id>'
Set-AzContext -Subscription "<Your-Azure_Subscription_Id>"

$body = "Hello Pravallika, This HTTP triggered function executed successfully."

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})

tasks.json:

{
    "version": "2.0.0",
    "tasks": [
{
    "label": "func start",
    "type": "shell",
    "command": "func start",
    "problemMatcher": "$func-powershell-watch",
    "isBackground": true
        }
    ]
}

host.json:

{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.3.0, 4.0.0)"
},
"managedDependency": {
"enabled": true
}
}

  • Uncomment the Az Modules in the requirements.txt file.
  • Make Sure you have the Local Storage Emulator or Azure Storage account connection String value in the local.settings.json such as "AzureWebJobsStorage": "UseDevelopmentStorage=true".
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.