Add metadata for bindings.azure.signalr (#2772)
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
parent
5dad8a867c
commit
26dea0c1c2
|
@ -0,0 +1,79 @@
|
|||
# yaml-language-server: $schema=../../../component-metadata-schema.json
|
||||
schemaVersion: "v1"
|
||||
type: "bindings"
|
||||
name: "azure.signalr"
|
||||
version: "v1"
|
||||
status: "alpha"
|
||||
title: "Azure SignalR"
|
||||
urls:
|
||||
- title: "Reference"
|
||||
url: "https://docs.dapr.io/reference/components-reference/supported-bindings/signalr/"
|
||||
binding:
|
||||
output: true
|
||||
input: false
|
||||
operations:
|
||||
- name: "create"
|
||||
description: "Send a message to SignalR"
|
||||
capabilities: []
|
||||
authenticationProfiles:
|
||||
- title: "Connection string with access key"
|
||||
description: "Authenticate using a connection string with an access key."
|
||||
metadata:
|
||||
- name: "connectionString"
|
||||
required: true
|
||||
sensitive: true
|
||||
description: "The Azure SignalR connection string."
|
||||
example: |
|
||||
"Endpoint=https://<your-azure-signalr>.service.signalr.net;AccessKey=<your-access-key>;Version=1.0;"
|
||||
- name: "endpoint"
|
||||
description: "Endpoint of Azure SignalR. Required if not included in the connection string."
|
||||
example: |
|
||||
"https://<your-azure-signalr>.service.signalr.net"
|
||||
- title: "Access key"
|
||||
description: "Authenticate using an access key."
|
||||
metadata:
|
||||
- name: "accessKey"
|
||||
required: true
|
||||
sensitive: true
|
||||
description: "The access key for Azure SignalR."
|
||||
example: |
|
||||
"your-access-key"
|
||||
- name: "endpoint"
|
||||
required: true
|
||||
description: "Endpoint of Azure SignalR. Required if not included in the connection string."
|
||||
example: |
|
||||
"https://<your-azure-signalr>.service.signalr.net"
|
||||
- title: "Connection string with Azure AD credentials"
|
||||
description: "Authenticate using Azure AD credentials defined in the connection string."
|
||||
metadata:
|
||||
- name: "connectionString"
|
||||
required: true
|
||||
sensitive: true
|
||||
description: |
|
||||
The Azure SignalR connection string containing Azure AD credentials. This includes the `AuthType=aad` option.
|
||||
Note that you cannot use a connection string if your application's ClientSecret contains a `;` character.
|
||||
# Note the example below contains Markdown inside a string
|
||||
example: |
|
||||
- With a system-assigned managed identity: `"Endpoint=https://<servicename>.service.signalr.net;AuthType=aad;Version=1.0;"`
|
||||
- With a user-assigned managed identity: `"Endpoint=https://<servicename>.service.signalr.net;AuthType=aad;ClientId=<clientid>;Version=1.0;"`
|
||||
- With an Azure AD application: `"Endpoint=https://<servicename>.service.signalr.net;AuthType=aad;ClientId=<clientid>;ClientSecret=<clientsecret>;TenantId=<tenantid>;Version=1.0;"`
|
||||
- name: "endpoint"
|
||||
description: "Endpoint of Azure SignalR. Required if not included in the connection string."
|
||||
example: |
|
||||
"https://<your-azure-signalr>.service.signalr.net"
|
||||
builtinAuthenticationProfiles:
|
||||
- name: "azuread"
|
||||
metadata:
|
||||
- name: "endpoint"
|
||||
description: "Endpoint of Azure SignalR"
|
||||
example: |
|
||||
"https://<your-azure-signalr>.service.signalr.net"
|
||||
required: true
|
||||
metadata:
|
||||
- name: "hub"
|
||||
description: |
|
||||
Defines the hub in which the message will be sent.
|
||||
This value can also be set for each invocation of the binding by passing the metadata option `hub`` with the invocation request.
|
||||
example: |
|
||||
"myhub"
|
||||
|
|
@ -16,6 +16,8 @@ package signalr
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -35,9 +37,6 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
errorPrefix = "azure signalr error:"
|
||||
logPrefix = "azure signalr:"
|
||||
|
||||
connectionStringKey = "connectionString"
|
||||
accessKeyKey = "accessKey"
|
||||
endpointKey = "endpoint"
|
||||
|
@ -63,6 +62,11 @@ var httpClient *http.Client
|
|||
func init() {
|
||||
httpClient = &http.Client{
|
||||
Timeout: 30 * time.Second,
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +196,7 @@ func (s *SignalR) resolveAPIURL(req *bindings.InvokeRequest) (string, error) {
|
|||
hub = s.hub
|
||||
}
|
||||
if hub == "" {
|
||||
return "", fmt.Errorf("%s missing hub", errorPrefix)
|
||||
return "", errors.New("missing hub")
|
||||
}
|
||||
|
||||
// Hub name is lower-cased in the official SDKs (e.g. .NET)
|
||||
|
@ -233,10 +237,10 @@ func (s *SignalR) sendMessageToSignalR(ctx context.Context, url string, token st
|
|||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted {
|
||||
return fmt.Errorf("%s azure signalr failed with code %d, content is '%s'", errorPrefix, resp.StatusCode, string(body))
|
||||
return fmt.Errorf("azure signalr failed with code %d, content is '%s'", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
s.logger.Debugf("%s azure signalr call to '%s' completed with code %d", logPrefix, url, resp.StatusCode)
|
||||
s.logger.Debugf("azure signalr call to '%s' completed with code %d", url, resp.StatusCode)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue