Skip to content

Conversation

Be3751
Copy link
Contributor

@Be3751 Be3751 commented Oct 5, 2024

Summary

The build settings have been changed so that the executable binary will run regardless of the execution environment.

Changes Made

  • Added CGO_ENABLED=0 when compiling custom handler for each OS.

Background

In the current document, the custom handler is built with dynamic link.
If you continue using this method, an error will occur when you deploy to Azure Functions, and the function will not run. That's presumably because the dependent C library is not placed in the execution environment. Therefore, I changed it to build the custom handler with static link.

Additional Notes

  • The need to set CGO_ENABLED=0 is described in the official Go documentation below.

The cgo tool is enabled by default for native builds on systems where it is expected to work. It is disabled by default when cross-compiling as well as when the CC environment variable is unset and the default C compiler (typically gcc or clang) cannot be found on the system PATH. You can override the default by setting the CGO_ENABLED environment variable when running the go tool: set it to 1 to enable the use of cgo, and to 0 to disable it.

https://pkg.go.dev/cmd/cgo

Copy link
Contributor

@Be3751 : Thanks for your contribution! The author(s) have been notified to review your proposed change.

Copy link
Contributor

Learn Build status updates of commit 8175a2e:

✅ Validation status: passed

File Status Preview URL Details
articles/azure-functions/create-first-function-vs-code-other.md ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@ShannonLeavitt
Copy link
Contributor

@ggailey777

Can you review the proposed changes?

IMPORTANT: When the changes are ready for publication, adding a #sign-off comment is the best way to signal that the PR is ready for the review team to merge.

#label:"aq-pr-triaged"
@MicrosoftDocs/public-repo-pr-review-team

@prmerger-automator prmerger-automator bot added the aq-pr-triaged tracking label for the PR review team label Oct 7, 2024
@Be3751
Copy link
Contributor Author

Be3751 commented Jan 4, 2025

hi, @ggailey777 .
any updates? Can you review this PR?

@v-dirichards
Copy link
Contributor

I sent an email to the content owner today.

@MicrosoftDocs/public-repo-pr-review-team

@ggailey777
Copy link
Contributor

ggailey777 commented May 20, 2025

The underlying issue here is that customers were creating function apps on Windows and deploying Golang apps build for Linux to Windows hosting. In this PR, we fix that so that customers are always creating Linux apps (currently Premium plan): https://github.com/MicrosoftDocs/azure-docs-pr/pull/300209
Thanks to @Be3751 for the potential fix, but it shouldn't be needed when the app runs correctly on Linux as designed. #please-close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants