Skip to content

Commit edd10ec

Browse files
Copilotliliankasem
andauthored
Improve publish error message when public network access is disabled (#4807)
* Initial plan * Improve publish action error message for SSL/network connection failures When public networking is disabled for an Azure Function App, deployments fail with the unhelpful 'The SSL connection could not be established, see inner exception.' message. This change: - Adds PublishNetworkingError constant with an improved message explaining the likely cause and an aka.ms link for guidance - Wraps publish operations in RunAsync() with an HttpRequestException catch that provides the improved error message while preserving the original error details Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com> * Update networking docs link and add release note entry for PR #4807 Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com> Co-authored-by: Lilian Kasem <likasem@microsoft.com>
1 parent e63fca5 commit edd10ec

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

release_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
- Support for custom bundle download paths via `AzureFunctionsJobHost__extensionBundle__downloadPath` environment variable
2525
- Added `--bundles-channel` option to `func init` command to specify extension bundle channel (GA, Preview, or Experimental) during project initialization
2626
- Fallback to cached bundles if there is no network connection during `func start` (#4772)
27-
- Added global `--offline` variable to run in offline mode (#4772)
27+
- Added global `--offline` variable to run in offline mode (#4772)
28+
- Improved error message for `func azure functionapp publish` when the connection fails due to networking restrictions, with a link to networking options documentation. (#4807)

src/Cli/func/Actions/AzureActions/PublishFunctionAppAction.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using System.Globalization;
5+
using System.Net.Http;
56
using System.Net.Http.Handlers;
67
using System.Net.Http.Headers;
78
using Azure.Functions.Cli.Actions.LocalActions;
@@ -240,13 +241,22 @@ public override async Task RunAsync()
240241
}
241242
else
242243
{
243-
if (PublishLocalSettingsOnly)
244+
try
244245
{
245-
await PublishLocalAppSettings(functionApp, additionalAppSettings);
246+
if (PublishLocalSettingsOnly)
247+
{
248+
await PublishLocalAppSettings(functionApp, additionalAppSettings);
249+
}
250+
else
251+
{
252+
await PublishFunctionApp(functionApp, ignoreParser, additionalAppSettings);
253+
}
246254
}
247-
else
255+
catch (HttpRequestException ex)
248256
{
249-
await PublishFunctionApp(functionApp, ignoreParser, additionalAppSettings);
257+
// HttpRequestException is thrown for connectivity failures (SSL, socket, DNS)
258+
// not for HTTP status errors, which are handled by CheckResponseStatusAsync as CliException.
259+
throw new CliException($"{Constants.Errors.PublishNetworkingError}{Environment.NewLine}Details: {ex.Message}", ex);
250260
}
251261
}
252262
}

src/Cli/func/Common/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public static class Errors
143143
public const string EitherPidOrAllMustBeSpecified = "Must specify either -a/--all or -p/--processId <Pid>";
144144
public const string ExtensionsNeedDotnet = "Extensions command requires dotnet on your path. Please make sure to install dotnet (.NET Core SDK) for your system from https://www.microsoft.com/net/download";
145145
public const string UnableToUpdateAppSettings = "Error updating Application Settings for the Function App for deployment.";
146+
public const string PublishNetworkingError = "Unable to connect to the Azure Function App. If public network access is disabled for this app, ensure you are deploying from an authorized network. For more information, see https://learn.microsoft.com/azure/azure-functions/functions-networking-options";
146147
public const string WebJobsStorageNotFound = "Missing value for AzureWebJobsStorage in {0}. This is required for all triggers other than {1}. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in {2}.";
147148
public const string WebJobsStorageNotFoundWithUserSecrets = "Missing value for AzureWebJobsStorage in {0} and User Secrets. This is required for all triggers other than {1}. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in {2} or User Secrets.";
148149
public const string AppSettingNotFound = "Warning: Cannot find value named '{0}' in {1} that matches '{2}' property set on '{3}' in '{4}'. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in {5}.";

0 commit comments

Comments
 (0)