cwyodmodules 0.3.76__py3-none-any.whl → 0.3.78__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,246 +1,416 @@
1
- """
2
- Azure Project Management Configuration Template
1
+ """Azure Project Management Configuration Template.
2
+
3
+ This module provides standardized configuration for Azure logging, identity management,
4
+ and Key Vault access across projects. It creates singleton instances that can be
5
+ imported and used throughout your application.
6
+
7
+ The configuration is driven by environment variables with sensible defaults, allowing
8
+ for flexible deployment across different environments (local development, staging,
9
+ production) without code changes.
3
10
 
4
- This template provides standardized configuration for Azure logging and identity
5
- management across projects. It creates singleton instances of AzureLogger and
6
- AzureIdentity that can be imported and used throughout your application.
11
+ Features:
12
+ - Automatic service detection (app vs function app)
13
+ - Configurable logging with Application Insights integration
14
+ - Azure identity management with token caching
15
+ - Key Vault integration for secrets, keys, and certificates
16
+ - Docker environment detection
17
+ - Local development environment setup
7
18
 
8
19
  Usage:
9
- from mgmt_config import logger, identity
20
+ Basic usage::
21
+
22
+ from mgmt_config import logger, identity
23
+
24
+ logger.info("Application started")
25
+ credential = identity.get_credential()
26
+
27
+ With Key Vault::
28
+
29
+ from mgmt_config import keyvault
30
+
31
+ if keyvault:
32
+ secret_value = keyvault.get_secret("my-secret")
33
+
34
+ Environment Variables:
35
+ Service Configuration:
36
+ REFLECTION_NAME: Service name for identification
37
+ REFLECTION_KIND: Service type (app, functionapp, etc.)
38
+ SERVICE_VERSION: Version of the service (default: "1.0.0")
10
39
 
11
- logger.info("Application started")
12
- credential = identity.get_credential()
40
+ Logging Configuration:
41
+ LOGGER_ENABLE_CONSOLE: Enable console logging (default: "true")
42
+ APPLICATIONINSIGHTS_CONNECTION_STRING: App Insights connection string
43
+
44
+ Identity Configuration:
45
+ IDENTITY_ENABLE_TOKEN_CACHE: Enable token caching (default: "true")
46
+ IDENTITY_ALLOW_UNENCRYPTED_STORAGE: Allow unencrypted token storage (default: "true")
47
+
48
+ Key Vault Configuration:
49
+ key_vault_uri: Primary Key Vault URL
50
+ head_key_vault_uri: Secondary Key Vault URL
51
+ KEYVAULT_ENABLE_SECRETS: Enable secrets client (default: "true")
52
+ KEYVAULT_ENABLE_KEYS: Enable keys client (default: "false")
53
+ KEYVAULT_ENABLE_CERTIFICATES: Enable certificates client (default: "false")
54
+
55
+ Examples:
56
+ Local Development:
57
+ Set REFLECTION_NAME and ensure .env file exists for local settings.
58
+
59
+ Azure Function App:
60
+ Set REFLECTION_KIND="functionapp" and REFLECTION_NAME to your function app name.
61
+
62
+ Web Application:
63
+ Set REFLECTION_KIND="app" (or leave default) and configure App Insights.
13
64
  """
14
65
 
15
66
  import os
16
- from typing import Optional, Dict, Any
17
- from azpaddypy.mgmt.logging import create_app_logger, create_function_logger
67
+ from typing import Any, Dict, Optional
68
+
18
69
  from azpaddypy.mgmt.identity import create_azure_identity
19
- from azpaddypy.resources.keyvault import create_azure_keyvault
20
70
  from azpaddypy.mgmt.local_env_manager import create_local_env_manager
21
-
22
- # Alias for import in other packages
71
+ from azpaddypy.mgmt.logging import create_app_logger, create_function_logger
72
+ from azpaddypy.resources.keyvault import create_azure_keyvault
23
73
 
24
74
  # =============================================================================
25
75
  # SERVICE CONFIGURATION
26
76
  # =============================================================================
27
77
 
28
- # Service identity - customize these for your project
29
- SERVICE_NAME = os.getenv("REFLECTION_NAME") or str("cwyodmodules")
30
- SERVICE_VERSION = os.getenv("SERVICE_VERSION", "1.0.0")
31
-
32
- def is_running_in_docker():
78
+ def _get_service_configuration() -> tuple[str, str, str]:
79
+ """Get service configuration from environment variables.
80
+
81
+ Returns:
82
+ A tuple containing (service_name, service_version, service_kind).
83
+
84
+ Note:
85
+ REFLECTION_KIND has commas replaced with hyphens for compatibility.
33
86
  """
34
- Checks if the current process is running inside a Docker container.
87
+ reflection_name = os.getenv("REFLECTION_NAME")
88
+ reflection_kind = os.getenv("REFLECTION_KIND", "").replace(",", "-")
89
+ service_name = reflection_name or str(__name__)
90
+ service_version = os.getenv("SERVICE_VERSION", "1.0.0")
91
+
92
+ return service_name, service_version, reflection_kind
93
+
94
+
95
+ SERVICE_NAME, SERVICE_VERSION, REFLECTION_KIND = _get_service_configuration()
96
+
97
+ # =============================================================================
98
+ # DOCKER ENVIRONMENT DETECTION
99
+ # =============================================================================
100
+
101
+ def is_running_in_docker() -> bool:
102
+ """Check if the current process is running inside a Docker container.
103
+
104
+ This function uses multiple detection methods to reliably identify
105
+ Docker environments across different container runtimes and orchestrators.
35
106
 
36
107
  Returns:
37
- bool: True if running in Docker, False otherwise.
108
+ True if running in Docker/container, False otherwise.
109
+
110
+ Detection Methods:
111
+ 1. Check for /.dockerenv file (standard Docker indicator)
112
+ 2. Check /proc/1/cgroup for container-specific entries
113
+ 3. Handles various container runtimes (Docker, Kubernetes, etc.)
38
114
  """
39
- # Method 1: Check for /.dockerenv file
115
+ # Method 1: Check for Docker environment file
40
116
  if os.path.exists('/.dockerenv'):
41
117
  return True
42
118
 
43
- # Method 2: Check cgroup for "docker"
119
+ # Method 2: Check process control groups for container indicators
44
120
  try:
45
- with open('/proc/1/cgroup', 'rt') as f:
121
+ with open('/proc/1/cgroup', 'rt', encoding='utf-8') as f:
46
122
  cgroup_content = f.read()
47
- if 'docker' in cgroup_content or 'kubepods' in cgroup_content:
48
- return True
49
- except FileNotFoundError:
50
- # /proc/1/cgroup does not exist, not a Linux-like environment
51
- pass
52
- except Exception:
53
- # Handle other potential exceptions, e.g., permissions
123
+ return any(indicator in cgroup_content
124
+ for indicator in ['docker', 'kubepods', 'containerd'])
125
+ except (FileNotFoundError, PermissionError, OSError):
126
+ # /proc filesystem not available or accessible (e.g., Windows, macOS)
54
127
  pass
55
128
 
56
129
  return False
57
130
 
58
- running_in_docker = is_running_in_docker()
59
- print("is_running_in_docker: " + str(running_in_docker))
60
131
 
132
+ RUNNING_IN_DOCKER = is_running_in_docker()
133
+ print(f"is_running_in_docker: {RUNNING_IN_DOCKER}")
61
134
 
62
135
  # =============================================================================
63
- # LOGGING CONFIGURATION
136
+ # LOCAL DEVELOPMENT CONFIGURATION
64
137
  # =============================================================================
65
138
 
66
- # Enable console output (useful for local development)
67
- LOGGER_ENABLE_CONSOLE = os.getenv("LOGGER_ENABLE_CONSOLE", "true").lower() == "true"
139
+ def _get_local_settings() -> Dict[str, str]:
140
+ """Get local development settings based on environment.
141
+
142
+ Returns:
143
+ Dictionary of local development settings appropriate for the environment.
144
+
145
+ Note:
146
+ Docker environments get Azure service principal settings,
147
+ while local environments get Azure Storage Emulator settings.
148
+ """
149
+ if RUNNING_IN_DOCKER:
150
+ return {
151
+ "AZURE_CLIENT_ID": "aa73da4a-2888-4cb7-896e-5d51125f11f0",
152
+ "AZURE_TENANT_ID": "e5590d5d-336c-4cf5-b0ac-b79a598ec797",
153
+ "AZURE_CLIENT_SECRET": "IQ08Q~4uCfc4B~p2F95D2737GzYvvrtIjursFbCf"
154
+ }
155
+ else:
156
+ return {
157
+ "AzureWebJobsStorage": "UseDevelopmentStorage=true",
158
+ "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
159
+ "input_queue_connection__queueServiceUri": "UseDevelopmentStorage=true",
160
+ "AzureWebJobsStorage__accountName": "UseDevelopmentStorage=true",
161
+ "AzureWebJobsStorage__blobServiceUri": "UseDevelopmentStorage=true",
162
+ }
163
+
164
+
165
+ # Initialize local environment manager
166
+ local_env_manager = create_local_env_manager(
167
+ file_path=".env",
168
+ settings=_get_local_settings(),
169
+ override_json=True,
170
+ override_dotenv=True,
171
+ override_settings=True,
172
+ )
68
173
 
69
- # Application Insights connection string (optional, will use environment variable if not set)
70
- LOGGER_CONNECTION_STRING = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
174
+ # =============================================================================
175
+ # LOGGING CONFIGURATION
176
+ # =============================================================================
71
177
 
72
- # Local development settings
73
- if running_in_docker:
74
- LOCAL_SETTINGS = {
75
- "AZURE_CLIENT_ID": "***",
76
- "AZURE_TENANT_ID": "***",
77
- "AZURE_CLIENT_SECRET": "***"
78
- }
79
- else:
80
- LOCAL_SETTINGS = {
81
- "AzureWebJobsStorage": "UseDevelopmentStorage=true",
82
- "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
83
- "input_queue_connection__queueServiceUri": "UseDevelopmentStorage=true",
84
- "AzureWebJobsStorage__accountName": "UseDevelopmentStorage=true",
85
- "AzureWebJobsStorage__blobServiceUri": "UseDevelopmentStorage=true",
178
+ def _get_logging_configuration() -> tuple[bool, Optional[str], Dict[str, Dict[str, bool]]]:
179
+ """Get logging configuration from environment variables.
180
+
181
+ Returns:
182
+ A tuple containing (console_enabled, connection_string, instrumentation_options).
183
+ """
184
+ console_enabled = os.getenv("LOGGER_ENABLE_CONSOLE", "true").lower() == "true"
185
+ connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
186
+
187
+ instrumentation_options = {
188
+ "azure_sdk": {"enabled": True},
189
+ "django": {"enabled": False},
190
+ "fastapi": {"enabled": False},
191
+ "flask": {"enabled": True},
192
+ "psycopg2": {"enabled": True},
193
+ "requests": {"enabled": True},
194
+ "urllib": {"enabled": True},
195
+ "urllib3": {"enabled": True},
86
196
  }
197
+
198
+ return console_enabled, connection_string, instrumentation_options
87
199
 
88
- # Configure which Azure SDK components to instrument
89
- LOGGER_INSTRUMENTATION_OPTIONS = {
90
- "azure_sdk": {"enabled": True},
91
- "django": {"enabled": False},
92
- "fastapi": {"enabled": False},
93
- "flask": {"enabled": True},
94
- "psycopg2": {"enabled": True},
95
- "requests": {"enabled": True},
96
- "urllib": {"enabled": True},
97
- "urllib3": {"enabled": True},
98
- }
200
+
201
+ LOGGER_ENABLE_CONSOLE, LOGGER_CONNECTION_STRING, LOGGER_INSTRUMENTATION_OPTIONS = _get_logging_configuration()
99
202
 
100
203
  # =============================================================================
101
204
  # IDENTITY CONFIGURATION
102
205
  # =============================================================================
103
206
 
104
- # Token caching settings
105
- IDENTITY_ENABLE_TOKEN_CACHE = os.getenv("IDENTITY_ENABLE_TOKEN_CACHE", "true").lower() == "true"
106
- IDENTITY_ALLOW_UNENCRYPTED_STORAGE = os.getenv("IDENTITY_ALLOW_UNENCRYPTED_STORAGE", "true").lower() == "true"
207
+ def _get_identity_configuration() -> tuple[bool, bool, Optional[Dict[str, Any]], Optional[str]]:
208
+ """Get identity configuration from environment variables.
209
+
210
+ Returns:
211
+ A tuple containing (token_cache_enabled, unencrypted_storage_allowed,
212
+ custom_options, connection_string).
213
+ """
214
+ token_cache_enabled = os.getenv("IDENTITY_ENABLE_TOKEN_CACHE", "true").lower() == "true"
215
+ unencrypted_storage_allowed = os.getenv("IDENTITY_ALLOW_UNENCRYPTED_STORAGE", "true").lower() == "true"
216
+ custom_options = None # Reserved for future custom credential configuration
217
+ connection_string = LOGGER_CONNECTION_STRING # Share with logger by default
218
+
219
+ return token_cache_enabled, unencrypted_storage_allowed, custom_options, connection_string
107
220
 
108
- # Custom credential options (None means use defaults)
109
- IDENTITY_CUSTOM_CREDENTIAL_OPTIONS: Optional[Dict[str, Any]] = None
110
221
 
111
- # Connection string for identity logging (uses same as logger by default)
112
- IDENTITY_CONNECTION_STRING = LOGGER_CONNECTION_STRING
222
+ (IDENTITY_ENABLE_TOKEN_CACHE,
223
+ IDENTITY_ALLOW_UNENCRYPTED_STORAGE,
224
+ IDENTITY_CUSTOM_CREDENTIAL_OPTIONS,
225
+ IDENTITY_CONNECTION_STRING) = _get_identity_configuration()
113
226
 
114
227
  # =============================================================================
115
- # KEYVAULT CONFIGURATION
228
+ # KEY VAULT CONFIGURATION
116
229
  # =============================================================================
117
230
 
118
- # Enable specific Key Vault client types
119
- KEYVAULT_ENABLE_SECRETS = os.getenv("KEYVAULT_ENABLE_SECRETS", "true").lower() == "true"
120
- KEYVAULT_ENABLE_KEYS = os.getenv("KEYVAULT_ENABLE_KEYS", "false").lower() == "true"
121
- KEYVAULT_ENABLE_CERTIFICATES = os.getenv("KEYVAULT_ENABLE_CERTIFICATES", "false").lower() == "true"
231
+ def _get_keyvault_configuration() -> tuple[Optional[str], Optional[str], bool, bool, bool, Optional[str]]:
232
+ """Get Key Vault configuration from environment variables.
233
+
234
+ Returns:
235
+ A tuple containing (vault_url, head_vault_url, secrets_enabled,
236
+ keys_enabled, certificates_enabled, connection_string).
237
+ """
238
+ vault_url = os.getenv("key_vault_uri")
239
+ head_vault_url = os.getenv("head_key_vault_uri")
240
+ secrets_enabled = os.getenv("KEYVAULT_ENABLE_SECRETS", "true").lower() == "true"
241
+ keys_enabled = os.getenv("KEYVAULT_ENABLE_KEYS", "false").lower() == "true"
242
+ certificates_enabled = os.getenv("KEYVAULT_ENABLE_CERTIFICATES", "false").lower() == "true"
243
+ connection_string = LOGGER_CONNECTION_STRING # Share with logger by default
244
+
245
+ return vault_url, head_vault_url, secrets_enabled, keys_enabled, certificates_enabled, connection_string
246
+
122
247
 
123
- # Connection string for keyvault logging (uses same as logger by default)
124
- KEYVAULT_CONNECTION_STRING = LOGGER_CONNECTION_STRING
248
+ (KEYVAULT_URL,
249
+ HEAD_KEYVAULT_URL,
250
+ KEYVAULT_ENABLE_SECRETS,
251
+ KEYVAULT_ENABLE_KEYS,
252
+ KEYVAULT_ENABLE_CERTIFICATES,
253
+ KEYVAULT_CONNECTION_STRING) = _get_keyvault_configuration()
125
254
 
126
255
  # =============================================================================
127
- # INITIALIZE SERVICES
256
+ # SERVICE INITIALIZATION
128
257
  # =============================================================================
129
258
 
130
- # Create logger instance
131
- if "functionapp" in os.getenv("REFLECTION_KIND", "app"):
132
- logger = create_function_logger(
133
- function_app_name=os.getenv("REFLECTION_NAME", "app"),
134
- function_name=os.getenv("REFLECTION_KIND", "app"),
135
- service_version=SERVICE_VERSION,
136
- connection_string=LOGGER_CONNECTION_STRING,
137
- instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
138
- )
139
- logger.info("Function logger initialized")
140
- else:
141
- logger = create_app_logger(
142
- service_name=SERVICE_NAME,
143
- service_version=SERVICE_VERSION,
144
- connection_string=LOGGER_CONNECTION_STRING,
145
- enable_console_logging=LOGGER_ENABLE_CONSOLE,
146
- instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
147
- )
148
- logger.info("App logger initialized")
149
-
150
- # Create identity instance with shared logger
151
- identity = create_azure_identity(
152
- service_name=SERVICE_NAME,
153
- service_version=SERVICE_VERSION,
154
- enable_token_cache=IDENTITY_ENABLE_TOKEN_CACHE,
155
- allow_unencrypted_storage=IDENTITY_ALLOW_UNENCRYPTED_STORAGE,
156
- custom_credential_options=IDENTITY_CUSTOM_CREDENTIAL_OPTIONS,
157
- connection_string=IDENTITY_CONNECTION_STRING,
158
- logger=logger,
159
- )
259
+ def _create_logger():
260
+ """Create and configure the appropriate logger instance.
261
+
262
+ Returns:
263
+ Configured AzureLogger instance (either app or function logger).
264
+
265
+ Note:
266
+ Logger type is determined by REFLECTION_KIND environment variable.
267
+ Function apps get specialized function loggers with additional context.
268
+ """
269
+ if "functionapp" in REFLECTION_KIND:
270
+ logger_instance = create_function_logger(
271
+ function_app_name=SERVICE_NAME,
272
+ function_name=REFLECTION_KIND,
273
+ service_version=SERVICE_VERSION,
274
+ connection_string=LOGGER_CONNECTION_STRING,
275
+ instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
276
+ )
277
+ logger_instance.info(
278
+ f"Function logger initialized: {REFLECTION_KIND} {SERVICE_NAME}",
279
+ extra={"logger_type": "function", "function_name": REFLECTION_KIND}
280
+ )
281
+ else:
282
+ logger_instance = create_app_logger(
283
+ service_name=SERVICE_NAME,
284
+ service_version=SERVICE_VERSION,
285
+ connection_string=LOGGER_CONNECTION_STRING,
286
+ enable_console_logging=LOGGER_ENABLE_CONSOLE,
287
+ instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
288
+ )
289
+ logger_instance.info(
290
+ f"App logger initialized: {REFLECTION_KIND} {SERVICE_NAME}",
291
+ extra={"logger_type": "app", "service_kind": REFLECTION_KIND}
292
+ )
293
+
294
+ return logger_instance
160
295
 
161
- # Azure Key Vault URL (required for Key Vault operations)
162
- KEYVAULT_URL = os.getenv("key_vault_uri")
163
- HEAD_KEYVAULT_URL = os.getenv("head_key_vault_uri")
164
296
 
165
- # Create keyvault instance with shared logger and identity (if URL is configured)
166
- keyvault = None
167
- if KEYVAULT_URL:
168
- keyvault = create_azure_keyvault(
169
- vault_url=KEYVAULT_URL,
170
- azure_identity=identity,
297
+ def _create_identity_manager(logger_instance):
298
+ """Create and configure the Azure identity manager.
299
+
300
+ Args:
301
+ logger_instance: Shared logger instance for identity operations.
302
+
303
+ Returns:
304
+ Configured AzureIdentity instance.
305
+ """
306
+ return create_azure_identity(
171
307
  service_name=SERVICE_NAME,
172
308
  service_version=SERVICE_VERSION,
173
- logger=logger,
174
- connection_string=KEYVAULT_CONNECTION_STRING,
175
- enable_secrets=KEYVAULT_ENABLE_SECRETS,
176
- enable_keys=KEYVAULT_ENABLE_KEYS,
177
- enable_certificates=KEYVAULT_ENABLE_CERTIFICATES,
309
+ enable_token_cache=IDENTITY_ENABLE_TOKEN_CACHE,
310
+ allow_unencrypted_storage=IDENTITY_ALLOW_UNENCRYPTED_STORAGE,
311
+ custom_credential_options=IDENTITY_CUSTOM_CREDENTIAL_OPTIONS,
312
+ connection_string=IDENTITY_CONNECTION_STRING,
313
+ logger=logger_instance,
178
314
  )
179
315
 
180
- head_keyvault = None
181
- if HEAD_KEYVAULT_URL:
182
- head_keyvault = create_azure_keyvault(
183
- vault_url=HEAD_KEYVAULT_URL,
184
- azure_identity=identity,
316
+
317
+ def _create_keyvault_client(vault_url: str, identity_instance, logger_instance):
318
+ """Create a Key Vault client for the specified vault.
319
+
320
+ Args:
321
+ vault_url: Azure Key Vault URL.
322
+ identity_instance: Shared identity manager.
323
+ logger_instance: Shared logger instance.
324
+
325
+ Returns:
326
+ Configured AzureKeyVault instance or None if creation fails.
327
+ """
328
+ if not vault_url:
329
+ return None
330
+
331
+ return create_azure_keyvault(
332
+ vault_url=vault_url,
333
+ azure_identity=identity_instance,
185
334
  service_name=SERVICE_NAME,
186
335
  service_version=SERVICE_VERSION,
187
- logger=logger,
336
+ logger=logger_instance,
188
337
  connection_string=KEYVAULT_CONNECTION_STRING,
189
338
  enable_secrets=KEYVAULT_ENABLE_SECRETS,
190
339
  enable_keys=KEYVAULT_ENABLE_KEYS,
191
340
  enable_certificates=KEYVAULT_ENABLE_CERTIFICATES,
192
341
  )
193
342
 
194
- # =============================================================================
195
- # VALIDATION & STARTUP
196
- # =============================================================================
197
343
 
198
- # Validate critical configuration
199
- if SERVICE_NAME == __name__:
200
- logger.warning(
201
- "SERVICE_NAME is not configured. Please set SERVICE_NAME environment variable or update this template.",
202
- extra={"configuration_issue": "service_name_not_set"}
203
- )
344
+ # Initialize core services
345
+ logger = _create_logger()
346
+ identity = _create_identity_manager(logger)
204
347
 
205
- if not LOGGER_CONNECTION_STRING:
206
- logger.info(
207
- "No Application Insights connection string configured. Telemetry will be disabled.",
208
- extra={"telemetry_status": "disabled"}
209
- )
348
+ # Initialize Key Vault clients (if URLs are configured)
349
+ keyvault = _create_keyvault_client(KEYVAULT_URL, identity, logger)
350
+ head_keyvault = _create_keyvault_client(HEAD_KEYVAULT_URL, identity, logger)
210
351
 
211
- if not KEYVAULT_URL:
212
- logger.info(
213
- "No Key Vault URL configured. Key Vault operations will be disabled.",
214
- extra={"keyvault_status": "disabled"}
215
- )
352
+ # =============================================================================
353
+ # CONFIGURATION VALIDATION & STARTUP LOGGING
354
+ # =============================================================================
216
355
 
217
- if not HEAD_KEYVAULT_URL:
356
+ def _validate_and_log_configuration():
357
+ """Validate configuration and log startup information.
358
+
359
+ This function performs validation checks and logs important configuration
360
+ status information for debugging and monitoring purposes.
361
+ """
362
+ # Validate critical configuration
363
+ if SERVICE_NAME == __name__:
364
+ logger.warning(
365
+ "SERVICE_NAME is using module name. Consider setting REFLECTION_NAME environment variable.",
366
+ extra={"configuration_issue": "service_name_not_set", "current_name": SERVICE_NAME}
367
+ )
368
+
369
+ # Log telemetry status
370
+ if not LOGGER_CONNECTION_STRING:
371
+ logger.info(
372
+ "No Application Insights connection string configured. Telemetry will be disabled.",
373
+ extra={"telemetry_status": "disabled"}
374
+ )
375
+
376
+ # Log Key Vault status
377
+ if not KEYVAULT_URL:
378
+ logger.info(
379
+ "No Key Vault URL configured. Key Vault operations will be disabled.",
380
+ extra={"keyvault_status": "disabled"}
381
+ )
382
+
383
+ if not HEAD_KEYVAULT_URL:
384
+ logger.info(
385
+ "No Head Key Vault URL configured. Head Key Vault operations will be disabled.",
386
+ extra={"head_keyvault_status": "disabled"}
387
+ )
388
+
389
+ # Log successful initialization with comprehensive metadata
218
390
  logger.info(
219
- "No Head Key Vault URL configured. Head Key Vault operations will be disabled.",
220
- extra={"head_keyvault_status": "disabled"}
391
+ f"Management configuration initialized for service '{SERVICE_NAME}' v{SERVICE_VERSION}",
392
+ extra={
393
+ "service_name": SERVICE_NAME,
394
+ "service_version": SERVICE_VERSION,
395
+ "console_logging": LOGGER_ENABLE_CONSOLE,
396
+ "token_cache_enabled": IDENTITY_ENABLE_TOKEN_CACHE,
397
+ "telemetry_enabled": bool(LOGGER_CONNECTION_STRING),
398
+ "keyvault_enabled": bool(KEYVAULT_URL),
399
+ "head_keyvault_enabled": bool(HEAD_KEYVAULT_URL),
400
+ "keyvault_secrets_enabled": KEYVAULT_ENABLE_SECRETS if KEYVAULT_URL else False,
401
+ "keyvault_keys_enabled": KEYVAULT_ENABLE_KEYS if KEYVAULT_URL else False,
402
+ "keyvault_certificates_enabled": KEYVAULT_ENABLE_CERTIFICATES if KEYVAULT_URL else False,
403
+ "running_in_docker": RUNNING_IN_DOCKER,
404
+ }
221
405
  )
222
406
 
223
- # Log successful initialization
224
- logger.info(
225
- f"Management configuration initialized for service '{SERVICE_NAME}' v{SERVICE_VERSION}",
226
- extra={
227
- "service_name": SERVICE_NAME,
228
- "service_version": SERVICE_VERSION,
229
- "console_logging": LOGGER_ENABLE_CONSOLE,
230
- "token_cache_enabled": IDENTITY_ENABLE_TOKEN_CACHE,
231
- "telemetry_enabled": bool(LOGGER_CONNECTION_STRING),
232
- "keyvault_enabled": bool(KEYVAULT_URL),
233
- "head_keyvault_enabled": bool(HEAD_KEYVAULT_URL),
234
- "keyvault_secrets_enabled": KEYVAULT_ENABLE_SECRETS if KEYVAULT_URL else False,
235
- "keyvault_keys_enabled": KEYVAULT_ENABLE_KEYS if KEYVAULT_URL else False,
236
- "keyvault_certificates_enabled": KEYVAULT_ENABLE_CERTIFICATES if KEYVAULT_URL else False,
237
- "running_in_docker": running_in_docker,
238
- }
239
- )
407
+
408
+ # Perform validation and startup logging
409
+ _validate_and_log_configuration()
240
410
 
241
411
  # =============================================================================
242
- # EXPORTS
412
+ # MODULE EXPORTS
243
413
  # =============================================================================
244
414
 
245
- # Export logger, identity, and keyvault for use in applications
415
+ # Export primary service instances for application use
246
416
  __all__ = ["logger", "local_env_manager", "identity", "keyvault", "head_keyvault"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cwyodmodules
3
- Version: 0.3.76
3
+ Version: 0.3.78
4
4
  Summary: Add your description here
5
5
  Author-email: Patrik <patrikhartl@gmail.com>
6
6
  Classifier: Operating System :: OS Independent
@@ -40,7 +40,7 @@ Requires-Dist: azure-search-documents==11.6.0b4
40
40
  Requires-Dist: semantic-kernel==1.3.0
41
41
  Requires-Dist: pydantic==2.7.4
42
42
  Requires-Dist: pandas>=2.2.3
43
- Requires-Dist: azpaddypy>=0.5.4
43
+ Requires-Dist: azpaddypy>=0.5.6
44
44
  Dynamic: license-file
45
45
 
46
46
  # paddypy
@@ -1,5 +1,5 @@
1
1
  cwyodmodules/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
2
- cwyodmodules/mgmt_config.py,sha256=EKE5_-8eTJpz-JIUFsIqbl_LjlFcjXcazokrk0pl2PY,9675
2
+ cwyodmodules/mgmt_config.py,sha256=Q4mjZzhbTCzSsxahIvyFsfi4KXJjvvQnL5HLVr71nks,16776
3
3
  cwyodmodules/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cwyodmodules/api/chat_history.py,sha256=bVXFmhTHIfEiHv_nBrfizO-cQRHhKgrdcZ07OD1b0Tw,20683
5
5
  cwyodmodules/batch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -109,8 +109,8 @@ cwyodmodules/graphrag/query/generate.py,sha256=BZiB6iw7PkIovw-CyYFogMHnDxK0Qu_4u
109
109
  cwyodmodules/graphrag/query/graph_search.py,sha256=95h3ecSWx4864XgKABtG0fh3Nk8HkqJVzoCrO8daJ-Y,7724
110
110
  cwyodmodules/graphrag/query/types.py,sha256=1Iq1dp4I4a56_cuFjOZ0NTgd0A2_MpVFznp_czgt6cI,617
111
111
  cwyodmodules/graphrag/query/vector_search.py,sha256=9Gwu9LPjtoAYUU8WKqCvbCHAIg3dpk71reoYd1scLnQ,1807
112
- cwyodmodules-0.3.76.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
113
- cwyodmodules-0.3.76.dist-info/METADATA,sha256=UCrw-PUMyhpdnQGobBZV-zsLQU3_5Jc2jxg4cKMeSPk,2002
114
- cwyodmodules-0.3.76.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
115
- cwyodmodules-0.3.76.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
116
- cwyodmodules-0.3.76.dist-info/RECORD,,
112
+ cwyodmodules-0.3.78.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
113
+ cwyodmodules-0.3.78.dist-info/METADATA,sha256=O7_6qxnbZI3ZGyuo-81smZwiDHZlgCWea37ZfAfSRNA,2002
114
+ cwyodmodules-0.3.78.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
115
+ cwyodmodules-0.3.78.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
116
+ cwyodmodules-0.3.78.dist-info/RECORD,,