Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect local function func start? What's the value of SharedAccessKey=SAS_KEY_VALUE #16

Open
ranma2913 opened this issue Jun 6, 2024 · 11 comments
Assignees

Comments

@ranma2913
Copy link

ranma2913 commented Jun 6, 2024

I'm developing a Javascript v4 function. It's working fine in cloud, but on local I'm not able to connect to my docker-compose started Event Hub Emulator.

I have Questions:

  • How do I produce events from my cli into theeventhubs-emulator
  • How do I setup the local.settings.json file?
  • Should SharedAccessKey=SAS_KEY_VALUE have some 'real' value instead of string 'SAS_KEY_VALUE'?

I'm using the connection string provided in the documentation Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true; but get a connection refused:

Functions:

        MyEventHubTrigger: eventHubTrigger

For detailed output, run func with --verbose flag.
[2024-06-06T16:52:49.253Z] Host lock lease acquired by instance ID '000000000000000000000000B4975DB8'.
[2024-06-06T16:52:56.304Z] EventProcessorHost error (Action='Retrieving list of partition identifiers from a Consumer Client.', HostName='52656bb6-5546-409b-a571-14550d79f670', PartitionId='').
[2024-06-06T16:52:56.304Z] System.Private.CoreLib: Connection refused.
[2024-06-06T16:52:56.313Z] The listener for function 'Functions.MyEventHubTrigger' was unable to start.
[2024-06-06T16:52:56.313Z] The listener for function 'Functions.MyEventHubTrigger' was unable to start. System.Private.CoreLib: One or more errors occurred. (Connection refused). System.Private.CoreLib: Connection refused.

Tagged in Redit Question here

@ranma2913 ranma2913 changed the title How to connect local function func start How to connect local function func start? What's the value of SharedAccessKey=SAS_KEY_VALUE Jun 6, 2024
@Saglodha Saglodha self-assigned this Jun 7, 2024
@Saglodha
Copy link
Contributor

@ranma2913 - You don't need to change anything for SharedAccessKey=SAS_KEY_VALUE. Other questions in your issue seems related to #15, can you review it to get more details on local.settings.json?

Additionally, I have similar questions on your setup- Where are the local function and emulator running and how does the networking topology look like?

@ranma2913
Copy link
Author

ranma2913 commented Jun 11, 2024

I'm starting the azure emulator with docker-compose like so:
image

docker-compose.yaml

name: microsoft-azure-emulators
services:
  emulator:
    container_name: "eventhubs-emulator"
    image: "mcr.microsoft.com/azure-messaging/eventhubs-emulator:latest"
    volumes:
      - "./eventhubs_emulator_config.json:/Eventhubs_Emulator/ConfigFiles/config.json"
    ports:
      - "5672:5672"
    environment:
      BLOB_SERVER: azurite
      METADATA_SERVER: azurite
      CONFIG_PATH: '/Eventhubs_Emulator/ConfigFiles/config.json'
      ACCEPT_EULA: 'Y'
    depends_on:
      - azurite
    networks:
      eh-emulator:
        aliases:
          - "eventhubs-emulator"
  azurite:
    container_name: "azurite"
    image: "mcr.microsoft.com/azure-storage/azurite:latest"
    ports:
      - "10000:10000"
      - "10001:10001"
      - "10002:10002"
    networks:
      eh-emulator:
        aliases:
          - "azurite"
networks:
  eh-emulator:

eventhubs_emulator_config.json

{
  "UserConfig" : {
    "NamespaceConfig" : [
      {
        "Type" : "EventHub",
        "Name" : "emulatorNs1",
        "Entities" : [
          {
            "Name" : "call-summary",
            "PartitionCount" : "2",
            "ConsumerGroups" : [
              {
                "Name" : "acet"
              }
            ]
          }
        ]
      }
    ],
    "LoggingConfig" : {
      "Type" : "Console,File"
    }
  }
}

And then I start the local function:

cd CallSummaryFunctionApp/
func start --verbose

image

BTW the local.settings.json =

{
  "IsEncrypted" : false,
  "Values" : {
    "AzureWebJobsStorage" : "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME" : "node",
    "SUMMARY_EVENT_HUB_NAME" : "call-summary",
    "SUMMARY_EVENT_HUB_CONNECTION" : "Endpoint=sb://localhost/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"
  }
}

@bitIO
Copy link

bitIO commented Jun 12, 2024

Hi, just my 2 cents.

From what I saw in my PoC using node is that coreamqp library is connecting to 5671 port (TLS port for amqp if I'm not wrong) which is not exposed by the docker compose. Adding it to the docker compose turns into a connection reset error.

Using the customEndpointAddress: "http://localhost:5672", in my EventHubProducerClient also results into a Failed to connecterror.

@ranma2913
Copy link
Author

I've added PR- #20 with my trial project. I've also tried explicitly installing the package Microsoft.Azure.WebJobs.Extensions.EventHubs as described in #15

@phs18
Copy link

phs18 commented Jun 21, 2024

@ranma2913
did your issue resolve and were you able to connect

@ranma2913
Copy link
Author

@phs18, sadly no I've not make any progress. Sample-Code-Snippets/JavaScript/EventHubTrigger-FunctionApp/src/functions/MyEventHubTrigger.js still sits without anyone from Azure getting a chance to look into this.

@kyrre
Copy link

kyrre commented Jul 2, 2024

I'm getting the exact same problem with a Python function. This is on M2.

eventhubs-emulator  | [11:38:11 WRN] <Trc Id="60006" Ch="Debug" Lvl="Warning" Kw="1000000000011110" UTC="2024-07-02T11:38:11.748Z" Msg="An exception was handled at YF. Exception message ExceptionId: e18c23ce-977e-486f-a4c7-e15654774ed6-System.OperationCanceledException: The operation was canceled.&#xA;   at E.EW.C[TAsyncResult](IAsyncResult)&#xA;   at g.gn.A.A(IAsyncResult)&#xA;   at g.gn.A(IAsyncResult)&#xA;   at Y.YF.A.a(IAsyncResult)&#xA;   at u.uL.A.A.a(A, IAsyncResult)&#xA;   at C.CJ`1.a(IAsyncResult)." />
eventhubs-emulator  | [11:38:11 WRN] <Trc Id="60006" Ch="Debug" Lvl="Warning" Kw="1000000000011110" UTC="2024-07-02T11:38:11.760Z" Msg="An exception was handled at Yg. Exception message ExceptionId: a21c0fca-17c6-4950-82ed-19ba6c2cde02-System.OperationCanceledException: The operation was canceled.&#xA;   at E.EW.C[TAsyncResult](IAsyncResult)&#xA;   at g.gn.A.A(IAsyncResult)&#xA;   at g.gn.A(IAsyncResult)&#xA;   at Y.Yg.A.a(IAsyncResult)&#xA;   at u.uL.A.A.a(A, IAsyncResult)&#xA;   at C.CJ`1.a(IAsyncResult)." />
eventhubs-emulator  | [11:38:14 WRN] <Trc Id="33029" Ch="Debug" Lvl="Warning" Kw="1000000000000008" UTC="2024-07-02T11:38:14.099Z" />
azurite             | 172.25.0.3 - - [02/Jul/2024:11:38:14 +0000] "PUT /devstoreaccount1/emulatorblobcontainer-e5bea00f9d744f21bed9928094d37424/INFO.ext?timeout=118 HTTP/1.1" 201 -
eventhubs-emulator  | [11:38:14 WRN] <Trc Id="60006" Ch="Debug" Lvl="Warning" Kw="1000000000011110" UTC="2024-07-02T11:38:14.368Z" Msg="An exception was handled at YF. Exception message ExceptionId: d63bfc07-8dd3-4a01-a48a-a792c237335f-System.OperationCanceledException: The operation was canceled.&#xA;   at E.EW.C[TAsyncResult](IAsyncResult)&#xA;   at g.gn.A.A(IAsyncResult)&#xA;   at g.gn.A(IAsyncResult)&#xA;   at Y.YF.A.a(IAsyncResult)&#xA;   at u.uL.A.A.a(A, IAsyncResult)&#xA;   at C.CJ`1.a(IAsyncResult)." />
eventhubs-emulator  | [11:38:14 WRN] <Trc Id="60006" Ch="Debug" Lvl="Warning" Kw="1000000000011110" UTC="2024-07-02T11:38:14.368Z" Msg="An exception was handled at YF. Exception message ExceptionId: a2f7e0df-73a8-4d30-8fc7-5f6f335857c1-System.OperationCanceledException: The operation was canceled.&#xA;   at E.EW.C[TAsyncResult](IAsyncResult)&#xA;   at g.gn.A.A(IAsyncResult)&#xA;   at g.gn.A(IAsyncResult)&#xA;   at Y.YF.A.a(IAsyncResult)&#xA;   at u.uL.A.A.a(A, IAsyncResult)&#xA;   at C.CJ`1.a(IAsyncResult)." />
azurite             | 172.25.0.3 - - [02/Jul/2024:11:38:18 +0000] "PUT /devstoreaccount1/emulatorblobcontainer-45582a30ca474b4aa79c4a9e5c603ee5/00000000.ext?comp=page&timeout=2 HTTP/1.1" 201 -
eventhubs-emulator  | [11:38:18 WRN] <Trc Id="60006" Ch="Debug" Lvl="Warning" Kw="1000000000011110" UTC="2024-07-02T11:38:18.903Z" Msg="An exception was handled at YF. Exception message ExceptionId: 7601dede-b77b-437a-91b8-945ed4f5714a-System.OperationCanceledException: The operation was canceled.&#xA;   at E.EW.C[TAsyncResult](IAsyncResult)&#xA;   at g.gn.A.A(IAsyncResult)&#xA;   at g.gn.A(IAsyncResult)&#xA;   at Y.YF.A.a(IAsyncResult)&#xA;   at u.uL.A.A.a(A, IAsyncResult)&#xA;   at C.CJ`1.a(IAsyncResult)." />


edit: this solved it: #15 (comment)

@Saglodha
Copy link
Contributor

Saglodha commented Jul 2, 2024

@phs18, sadly no I've not make any progress. Sample-Code-Snippets/JavaScript/EventHubTrigger-FunctionApp/src/functions/MyEventHubTrigger.js still sits without anyone from Azure getting a chance to look into this.

@ranma2913 - I posted a comment on the sample that you provided. Could you please review? Similar to @kyrre, I was also able to run it successfully on my local machine

@Saglodha
Copy link
Contributor

@ranma2913 - could you please confirm if you had a chance to look at above feedback? Are you still facing the issue?

@mirkoiv
Copy link

mirkoiv commented Aug 22, 2024

The issue is the same as one I encountered with a Java Spring Azure application. As previously mentioned, an Azure Function attempts to connect to the Event Hubs Emulator on port 5671.

I'm using the emulator to develop both Java Spring Azure application and Azure Functions in TypeScript, but with a reverse proxy in front of the emulator.

For more details about this workaround check this link: https://github.com/mirkoiv/azure-event-hubs-emulator-installer/blob/main/Sample-Code-Snippets/Java/spring-cloud-azure-samples/README.md.

To make this workaround work with Azure Functions, ensure that the generated certificate for the Nginx reverse proxy is added to the computer's trusted root certificate store.

@huykon
Copy link

huykon commented Oct 10, 2024

can we change the default port 5672 to another ? because 5672 is the redis port on my docker

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

No branches or pull requests

7 participants