Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
template: real-time-intelligence-operations-solution-accelerator@1.0

requiredVersions:
azd: ">= 1.19.0"
azd: ">= 1.19.0 != 1.23.9"

hooks:
postprovision:
Expand Down
5 changes: 5 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ var allTags = union(
tags
)

var eventHubTags = union(allTags, {
SecurityControl: 'Ignore' // Required to override MSFT subscription policy controls that enforce disableLocalAuth; local auth needed for Fabric SAS connection
})

resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
name: 'default'
properties: {
Expand Down Expand Up @@ -142,6 +146,7 @@ module eventHubNamespaceModule 'br/public:avm/res/event-hub/namespace:0.13.0' =
skuName: 'Standard'
skuCapacity: 1
disableLocalAuth: false // NOTE: local auth is currently needed in order to create connection with Fabric via SAS token
tags: eventHubTags
eventhubs: [
{
name: eventHubName
Expand Down
1 change: 0 additions & 1 deletion infra/scripts/fabric/fabric_activator_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import os
import re
import sys
from typing import Dict, Any, Optional

from fabric_api import FabricWorkspaceApiClient, FabricApiError

Expand Down
40 changes: 39 additions & 1 deletion infra/scripts/fabric/fabric_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ def _format_duration(self, elapsed_seconds: float) -> str:
minutes = int(elapsed_seconds // 60)
seconds = int(elapsed_seconds % 60)
return f"{minutes}m {seconds}s"

@staticmethod
def _normalize_eventhub_endpoint(namespace_or_endpoint: str) -> str:
"""Normalize Event Hub endpoint to the connector-expected host format.

Accepts either a bare namespace (e.g. "myns") or a full endpoint
(e.g. "sb://myns.servicebus.windows.net/") and returns
"myns.servicebus.windows.net".
"""
endpoint = (namespace_or_endpoint or "").strip()
if endpoint.startswith("sb://"):
endpoint = endpoint[len("sb://"):]
endpoint = endpoint.rstrip("/")
if ".servicebus.windows.net" not in endpoint:
endpoint = f"{endpoint}.servicebus.windows.net"
return endpoint

def start_long_running_operation(self,
uri: str,
Expand Down Expand Up @@ -759,6 +775,8 @@ def create_eventhub_connection(self, name: str, namespace_name: str, event_hub_n
"""
self._log(f"Creating Event Hub connection: {name}")

normalized_endpoint = self._normalize_eventhub_endpoint(namespace_name)

connection_payload = {
"displayName": name,
"connectivityType": "ShareableCloud",
Expand All @@ -770,7 +788,7 @@ def create_eventhub_connection(self, name: str, namespace_name: str, event_hub_n
{
"name": "endpoint",
"dataType": "Text",
"value": namespace_name,
"value": normalized_endpoint,
},
{
"name": "entityPath",
Expand All @@ -780,6 +798,7 @@ def create_eventhub_connection(self, name: str, namespace_name: str, event_hub_n
]
},
"credentialDetails": {
"singleSignOnType": "None",
"credentials": {
"credentialType": "Basic", # the endpoint only accepts Basic auth, but takes SAS key with policy name as password and username
"username": shared_access_policy_name, #"RootManageSharedAccessKey",
Expand Down Expand Up @@ -818,11 +837,30 @@ def update_eventhub_connection(self, connection_id: str, name: str, namespace_na
try:
self._log(f"Updating Event Hub connection: {name} (ID: {connection_id})")

normalized_endpoint = self._normalize_eventhub_endpoint(namespace_name)

connection_payload = {
"displayName": name,
"connectivityType": "ShareableCloud",
"allowConnectionUsageInGateway": False,
"connectionDetails": {
"type": "EventHub",
"creationMethod": "EventHub.Contents",
"parameters": [
{
"name": "endpoint",
"dataType": "Text",
"value": normalized_endpoint,
},
{
"name": "entityPath",
"dataType": "Text",
"value": event_hub_name,
}
]
},
"credentialDetails": {
"singleSignOnType": "None",
"credentials": {
"credentialType": "Basic", # the endpoint only accepts Basic auth, but takes SAS key with policy name as password and username
"username": shared_access_policy_name,
Expand Down
1 change: 0 additions & 1 deletion infra/scripts/fabric/fabric_common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import os
import sys
import argparse
from datetime import datetime

def get_required_env_var(var_name: str) -> str:
Expand Down
4 changes: 1 addition & 3 deletions infra/scripts/fabric/fabric_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
- Access to the specified Fabric cluster and database
"""

import argparse
import os
import sys
from pathlib import Path

Expand All @@ -25,7 +23,7 @@
sys.path.insert(0, str(scripts_dir))

from azure.identity import AzureCliCredential
from azure.kusto.data import KustoClient, KustoConnectionStringBuilder, ClientRequestProperties
from azure.kusto.data import KustoClient, KustoConnectionStringBuilder
from azure.kusto.data.exceptions import KustoServiceError

def create_kusto_client(cluster_uri) -> KustoClient:
Expand Down
2 changes: 1 addition & 1 deletion infra/scripts/fabric/fabric_eventhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import argparse
import sys
import time
from typing import Optional, Dict, Any
from typing import Optional
from fabric_api import FabricWorkspaceApiClient, FabricApiError


Expand Down
1 change: 0 additions & 1 deletion infra/scripts/fabric/fabric_eventhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"""

import argparse
import sys
from azure.identity import AzureCliCredential
from azure.mgmt.eventhub import EventHubManagementClient
from fabric_api import FabricApiClient, FabricApiError
Expand Down
1 change: 0 additions & 1 deletion infra/scripts/fabric/fabric_eventstream_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import json
import os
import sys
from typing import Dict, Any, Optional
from fabric_api import FabricWorkspaceApiClient, FabricApiError
from fabric_auth import authenticate_workspace

Expand Down
1 change: 0 additions & 1 deletion infra/scripts/fabric/fabric_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""

import argparse
import sys
from fabric_api import FabricApiClient, FabricWorkspaceApiClient, FabricApiError

def setup_workspace(fabric_client: FabricApiClient, capacity_name: str, workspace_name: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion infra/scripts/fabric/graph_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import time
import uuid
from datetime import datetime, timedelta
from typing import Dict, List, Optional, Union, Any, Tuple
from typing import Dict, Optional, Union, Any, Tuple
from azure.identity import AzureCliCredential


Expand Down
Loading