Skip to content

Commit 55ce7e8

Browse files
committed
support diff domains for the storage account url
1 parent 9deb528 commit 55ce7e8

File tree

2 files changed

+60
-14
lines changed

2 files changed

+60
-14
lines changed

docs/reference/filebeat/filebeat-input-azure-eventhub.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,78 @@ Users can make use of the `azure-eventhub` input in order to read messages from
1212

1313
Users can enable internal logs tracing for this input by setting the environment variable `BEATS_AZURE_EVENTHUB_INPUT_TRACING_ENABLED: true`. When enabled, this input will log additional information to the logs. Additional information includes partition ownership, blob lease information, and other internal state.
1414

15-
Example configuration using Shared Access Key authentication:
15+
## Example configurations
16+
17+
### Connection string authentication (processor v1)
18+
19+
Example configuration using connection string authentication with processor v1:
1620

1721
```yaml
1822
filebeat.inputs:
1923
- type: azure-eventhub
2024
eventhub: "insights-operational-logs"
21-
consumer_group: "test"
22-
connection_string: "Endpoint=sb://....."
23-
storage_account: "azureeph"
24-
storage_account_key: "....."
25-
storage_account_container: ""
26-
resource_manager_endpoint: ""
25+
consumer_group: "$Default"
26+
# Connection string authentication (default)
27+
connection_string: "Endpoint=sb://your-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=your-shared-access-key"
28+
# Storage account configuration
29+
storage_account: "your-storage-account"
30+
storage_account_key: "your-storage-account-key"
31+
storage_account_container: "" # Optional: defaults to filebeat-<eventhub-name>
32+
processor_version: "v1"
33+
# Optional: for non-public Azure clouds
34+
# resource_manager_endpoint: "https://management.usgovcloudapi.net/" # For Azure Government
2735
```
2836

29-
{applies_to}`stack: ga 9.3.0` Example configuration using client secret authentication:
37+
### Connection string authentication (processor v2)
38+
39+
Example configuration using connection string authentication with processor v2:
3040

3141
```yaml
3242
filebeat.inputs:
3343
- type: azure-eventhub
3444
eventhub: "insights-operational-logs"
35-
consumer_group: "test"
45+
consumer_group: "$Default"
46+
# Connection string authentication (default)
47+
auth_type: "connection_string"
48+
connection_string: "Endpoint=sb://your-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=your-shared-access-key"
49+
# Storage account configuration
50+
storage_account: "your-storage-account"
51+
storage_account_connection_string: "DefaultEndpointsProtocol=https;AccountName=your-storage-account;AccountKey=your-storage-account-key;EndpointSuffix=core.windows.net"
52+
storage_account_container: "" # Optional: defaults to filebeat-<eventhub-name>
53+
processor_version: "v2"
54+
# Optional: for non-public Azure clouds
55+
# resource_manager_endpoint: "https://management.usgovcloudapi.net/" # For Azure Government
56+
```
57+
58+
{applies_to}`stack: ga 9.3.0` ### Client secret authentication (processor v2)
59+
60+
Example configuration using Azure Active Directory service principal authentication with processor v2:
61+
62+
```yaml
63+
filebeat.inputs:
64+
- type: azure-eventhub
65+
eventhub: "insights-operational-logs"
66+
consumer_group: "$Default"
67+
# Client secret authentication
3668
auth_type: "client_secret"
37-
eventhub_namespace: "your-eventhub-namespace.servicebus.windows.net"
69+
eventhub_namespace: "your-namespace.servicebus.windows.net"
3870
tenant_id: "your-tenant-id"
3971
client_id: "your-client-id"
4072
client_secret: "your-client-secret"
73+
# Optional: defaults to Azure Public Cloud
4174
authority_host: "https://login.microsoftonline.com"
42-
storage_account: "azureeph"
43-
storage_account_container: ""
75+
# For Azure Government, use: "https://login.microsoftonline.us"
76+
# For Azure China, use: "https://login.chinacloudapi.cn"
77+
# Storage account configuration
78+
storage_account: "your-storage-account"
79+
storage_account_container: "" # Optional: defaults to filebeat-<eventhub-name>
4480
processor_version: "v2"
81+
# Optional: for non-public Azure clouds
82+
# resource_manager_endpoint: "https://management.usgovcloudapi.net/" # For Azure Government
4583
```
4684

85+
**Note:** When using `client_secret` authentication, the service principal must have the appropriate Azure RBAC permissions. See [Required permissions](#_required_permissions) for details.
86+
4787
## Authentication [_authentication]
4888

4989
The azure-eventhub input supports multiple authentication methods. The [`auth_type` configuration option](#_auth_type) controls the authentication method used for both Event Hub and Storage Account.

x-pack/filebeat/input/azureeventhub/auth.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,14 @@ func CreateStorageAccountContainerClient(cfg *azureInputConfig, log *logp.Logger
153153
return nil, fmt.Errorf("credential cannot be empty when auth_type is client_secret")
154154
}
155155

156-
// Build the storage account URL
157-
storageAccountURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s", cfg.SAName, cfg.SAContainer)
156+
// Get the Azure environment to determine the correct storage endpoint suffix
157+
env, err := getAzureEnvironment(cfg.OverrideEnvironment)
158+
if err != nil {
159+
return nil, fmt.Errorf("failed to get azure environment: %w", err)
160+
}
161+
162+
// Build the storage account URL using the correct endpoint suffix for the cloud environment
163+
storageAccountURL := fmt.Sprintf("https://%s.blob.%s/%s", cfg.SAName, env.StorageEndpointSuffix, cfg.SAContainer)
158164
containerClient, err := container.NewClient(storageAccountURL, credential, nil)
159165
if err != nil {
160166
return nil, fmt.Errorf("failed to create container client with credential: %w", err)

0 commit comments

Comments
 (0)