Skip to content

Commit

Permalink
add support for passing azure app registration credentials as integra…
Browse files Browse the repository at this point in the history
…tion config
  • Loading branch information
Tankilevitch committed Jun 27, 2024
1 parent 8bc44d7 commit 4679708
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
29 changes: 28 additions & 1 deletion integrations/azure/.port/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,35 @@ features:
- kind: storageContainer
saas:
enabled: false
configurations: []
configurations:
- name: azureClientId
required: false
type: string
sensitive: true
description: Azure Client ID, for more information on how to create and manage the Credentials see here https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal.
- name: azureClientSecret
required: false
type: string
sensitive: true
description: Azure Client Secret, for more information on how to create and manage the Credentials see here information https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal.
- name: azureTenantId
required: false
type: string
sensitive: true
description: Azure Tenant ID, for more information on how to create and manage the Credentials see here https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal.
- name: azureSubscriptionId
required: false
type: string
sensitive: true
description: Azure Subscription ID, for more information on how to create and manage the Credentials see here https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal.
deploymentMethodRequirements:
- type: default
configurations: ['azureClientId', 'azureClientSecret', 'azureTenantId', 'azureSubscriptionId']
deploymentMethodOverride:
- type: helm
- type: docker
- type: githubWorkflow
- type: gitlabCI
- type: terraform
module: port-labs/integration-factory/ocean
example: azure_container_app_azure_integration
Expand Down
7 changes: 7 additions & 0 deletions integrations/azure/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.1.67 (2024-06-27)

### Improvements

- Added support for default installation methods ( Helm, docker, githubworkflow and gitlabCI ) to improve ease of use (#1)


0.1.66 (2024-06-23)

### Improvements
Expand Down
39 changes: 39 additions & 0 deletions integrations/azure/azure_integration/ocean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import http
import os
import typing

from cloudevents.pydantic import CloudEvent
Expand Down Expand Up @@ -279,3 +280,41 @@ async def cloud_event_validation_middleware_handler(
return response

return await call_next(request)


@ocean.on_start()
async def on_start() -> None:

logger.info("Setting up credentials for Azure client")
azure_client_id = ocean.integration_config.get("azure_client_id")
azure_client_secret = ocean.integration_config.get("azure_client_secret")
azure_tenant_id = ocean.integration_config.get("azure_tenant_id")
azure_subscription_id = ocean.integration_config.get("azure_subscription_id")
if not azure_client_id and not azure_client_secret and not azure_tenant_id:
logger.info(
"Integration wasn't provided with override configuration for initializing client, proceeding with default"
)
return

if azure_client_id:
logger.info(
"Detected Azure client id, setting up environment variable for client id"
)
os.environ["AZURE_CLIENT_ID"] = azure_client_id
if azure_client_secret:
logger.info(
"Detected Azure client secret, setting up environment variable for client secret"
)
os.environ["AZURE_CLIENT_SECRET"] = azure_client_secret
if azure_tenant_id:
logger.info(
"Detected Azure tenant id, setting up environment variable for tenant id"
)
os.environ["AZURE_TENANT_ID"] = azure_tenant_id
if azure_subscription_id:
logger.info(
"Detected Azure subscription id, setting up environment variable for subscription id"
)
os.environ["AZURE_SUBSCRIPTION_ID"] = azure_subscription_id

logger.info("Azure client credentials set up")

0 comments on commit 4679708

Please sign in to comment.