From 1b7aeecf9c07f43f80fce2e5e07e5d1c9a306786 Mon Sep 17 00:00:00 2001 From: Kozimov Date: Wed, 6 Sep 2023 14:05:40 +0200 Subject: [PATCH 1/4] PCLOUDS-2709 hotfix --- deployment/dynatrace-azure-forwarder.json | 7 ++++--- deployment/dynatrace-azure-logs.sh | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/dynatrace-azure-forwarder.json b/deployment/dynatrace-azure-forwarder.json index bc895fc..9881ce5 100644 --- a/deployment/dynatrace-azure-forwarder.json +++ b/deployment/dynatrace-azure-forwarder.json @@ -30,6 +30,7 @@ }, "eventHubConnectionString": { "type": "string", + "defaultValue": "", "metadata": { "description": "Event hub connection string" } @@ -451,15 +452,15 @@ "value": "[parameters('filterConfig')]" }, { - "name": "EventHubConnection_clientId", + "name": "EVENTHUB_CONNECTION_STRING__clientId", "value": "[parameters('eventhubConnectionClientId')]" }, { - "name": "EventHubConnection_credential", + "name": "EVENTHUB_CONNECTION_STRING__credential", "value": "[parameters('eventhubConnectionCredentials')]" }, { - "name": "EventHubConnection_fullyQualifiedNamespace", + "name": "EVENTHUB_CONNECTION_STRING__fullyQualifiedNamespace", "value": "[parameters('eventhubConnectionFullyQualifiedNamespace')]" } ] diff --git a/deployment/dynatrace-azure-logs.sh b/deployment/dynatrace-azure-logs.sh index 920fb45..4b7f740 100755 --- a/deployment/dynatrace-azure-logs.sh +++ b/deployment/dynatrace-azure-logs.sh @@ -392,7 +392,6 @@ if [ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" = "true" ]; then --parameters forwarderName="${DEPLOYMENT_NAME}" \ targetUrl="${TARGET_URL}" \ targetAPIToken="${TARGET_API_TOKEN}" \ - eventHubConnectionString="${EVENT_HUB_CONNECTION_STRING}" \ eventHubName="${EVENT_HUB_NAME}" \ requireValidCertificate=${REQUIRE_VALID_CERTIFICATE} \ selfMonitoringEnabled="${SFM_ENABLED}" \ From 7270b59003ecccd2a88a5f882fe4f1775e8dd471 Mon Sep 17 00:00:00 2001 From: Kozimov Date: Thu, 7 Sep 2023 06:52:11 +0200 Subject: [PATCH 2/4] PCLOUDS-2709 Fixed not passing Eventhub-connection-string when MI is used --- deployment/dynatrace-azure-logs.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/deployment/dynatrace-azure-logs.sh b/deployment/dynatrace-azure-logs.sh index 4b7f740..6a58262 100755 --- a/deployment/dynatrace-azure-logs.sh +++ b/deployment/dynatrace-azure-logs.sh @@ -50,6 +50,8 @@ arguments: Name of the Azure Resource Group in which Function will be deployed --event-hub-connection-string EVENT_HUB_CONNECTION_STRING Connection string for Azure EventHub that is configured for receiving logs + --event-hub-name EVENT_HUB_NAME + Required only when using user-assigned MI. Azure EventHub name that is configured for receiving logs --tags TAGS Comma separated tag:value pairs added to Azure resources during azure-log-forwarder deployment e.g. \"tagName:value,tagName2:value2,tagName3:value3\" @@ -63,7 +65,7 @@ arguments: Change repository url to custom. Do not change without specific reason --enable-user-assigned-managed-identity {true|false} Optional, 'false' by default - if you choose to use user-assigned-managed-identity, you need to change it to 'true' and provide EVENT_HUB_CONNECTION_CLIENT_ID, MANAGED_IDENTITY_RESOURCE_NAME and EVENT_HUB_CONNECTION_FULLY_QUALIFIED_NAMESPACE + if you choose to use user-assigned-managed-identity, you need to change it to 'true' and provide EVENT_HUB_CONNECTION_CLIENT_ID, MANAGED_IDENTITY_RESOURCE_NAME, EVENT_HUB_CONNECTION_FULLY_QUALIFIED_NAMESPACE and EVENT_HUB_NAME --eventhub-connection-client-id EVENT_HUB_CONNECTION_CLIENT_ID The client id of User-Assigned MI --managed-identity-resource-name MANAGED_IDENTITY_RESOURCE_NAME @@ -89,7 +91,7 @@ print_all_parameters() { if [[ "$USE_EXISTING_ACTIVE_GATE" == "false" ]]; then PARAMETERS+=", TARGET_PAAS_TOKEN=*****"; fi if [ -n "$FILTER_CONFIG" ]; then PARAMETERS+=", FILTER_CONFIG=$FILTER_CONFIG"; fi if [ -n "$TAGS" ]; then PARAMETERS+=", TAGS=$TAGS"; fi - if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "true" ]]; then PARAMETERS+=", EVENT_HUB_CONNECTION_CLIENT_ID=$EVENT_HUB_CONNECTION_CLIENT_ID, MANAGED_IDENTITY_RESOURCE_NAME=$MANAGED_IDENTITY_RESOURCE_NAME, EVENT_HUB_CONNECTION_FULLY_QUALIFIED_NAMESPACE=$EVENT_HUB_CONNECTION_FULLY_QUALIFIED_NAMESPACE"; fi + if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "true" ]]; then PARAMETERS+="EVENT_HUB_NAME=$EVENT_HUB_NAME, EVENT_HUB_CONNECTION_CLIENT_ID=$EVENT_HUB_CONNECTION_CLIENT_ID, MANAGED_IDENTITY_RESOURCE_NAME=$MANAGED_IDENTITY_RESOURCE_NAME, EVENT_HUB_CONNECTION_FULLY_QUALIFIED_NAMESPACE=$EVENT_HUB_CONNECTION_FULLY_QUALIFIED_NAMESPACE"; fi echo echo "Deployment script will use following parameters:" echo $PARAMETERS @@ -216,6 +218,12 @@ while (( "$#" )); do shift; shift ;; + "--event-hub-name") + ensure_param_value_given $1 $2 + EVENT_HUB_NAME=$2 + shift; shift + ;; + "--filter-config") ensure_param_value_given $1 $2 FILTER_CONFIG=$2 @@ -305,7 +313,9 @@ fi check_arg --deployment-name "$DEPLOYMENT_NAME" "$DEPLOYMENT_NAME_REGEX" check_arg --resource-group "$RESOURCE_GROUP" ".+" -check_arg --event-hub-connection-string "$EVENT_HUB_CONNECTION_STRING" "$EVENT_HUB_CONNECTION_STRING_REGEX" +if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]]; then + check_arg --event-hub-connection-string "$EVENT_HUB_CONNECTION_STRING" "$EVENT_HUB_CONNECTION_STRING_REGEX" +fi if [ -z "$REQUIRE_VALID_CERTIFICATE" ]; then REQUIRE_VALID_CERTIFICATE=$REQUIRE_VALID_CERTIFICATE_DEFAULT; fi if [ -z "$SFM_ENABLED" ]; then SFM_ENABLED=false; fi @@ -354,6 +364,7 @@ if [[ "$USE_EXISTING_ACTIVE_GATE" == true ]]; then DEPLOY_ACTIVEGATE=false;else if [ -z "$REPOSITORY_RELEASE_URL" ]; then REPOSITORY_RELEASE_URL=${FUNCTION_REPOSITORY_RELEASE_URL}; fi if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "true" ]]; then EVENT_HUB_CONNECTION_CREDENTIALS="managedidentity"; + if [ -z "$EVENT_HUB_NAME" ]; then echo "No --event-hub-name"; exit 1; fi if [ -z "$EVENT_HUB_CONNECTION_CLIENT_ID" ]; then echo "No --eventhub-connection-client-id"; exit 1; fi if [ -z "$MANAGED_IDENTITY_RESOURCE_NAME" ]; then echo "No --managed-identity-resource-name"; exit 1; fi if [ -z "$EVENT_HUB_CONNECTION_FULLY_QUALIFIED_NAMESPACE" ]; then echo "No --eventhub-connection-fully-qualified-namespace"; exit 1; fi @@ -373,7 +384,9 @@ if [[ "${DEPLOY_ACTIVEGATE}" == "false" ]]; then check_dynatrace_log_ingest_url fi -EVENT_HUB_NAME=$(echo "$EVENT_HUB_CONNECTION_STRING" | awk -F ';EntityPath=' '{print $2}') +if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]]; then + EVENT_HUB_NAME=$(echo "$EVENT_HUB_CONNECTION_STRING" | awk -F ';EntityPath=' '{print $2}') +fi echo "- deploying function infrastructure into Azure..." From 6a7948e658797310ff68eab813d808ccc2abe022 Mon Sep 17 00:00:00 2001 From: Kozimov Date: Thu, 7 Sep 2023 06:59:11 +0200 Subject: [PATCH 3/4] PCLOUDS-2709 Clean up --- deployment/dynatrace-azure-logs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/dynatrace-azure-logs.sh b/deployment/dynatrace-azure-logs.sh index 6a58262..35d93f5 100755 --- a/deployment/dynatrace-azure-logs.sh +++ b/deployment/dynatrace-azure-logs.sh @@ -313,7 +313,7 @@ fi check_arg --deployment-name "$DEPLOYMENT_NAME" "$DEPLOYMENT_NAME_REGEX" check_arg --resource-group "$RESOURCE_GROUP" ".+" -if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]]; then +if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]] || [[ -z "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" ]]; then check_arg --event-hub-connection-string "$EVENT_HUB_CONNECTION_STRING" "$EVENT_HUB_CONNECTION_STRING_REGEX" fi if [ -z "$REQUIRE_VALID_CERTIFICATE" ]; then REQUIRE_VALID_CERTIFICATE=$REQUIRE_VALID_CERTIFICATE_DEFAULT; fi @@ -384,7 +384,7 @@ if [[ "${DEPLOY_ACTIVEGATE}" == "false" ]]; then check_dynatrace_log_ingest_url fi -if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]]; then +if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]] || [[ ]]; then EVENT_HUB_NAME=$(echo "$EVENT_HUB_CONNECTION_STRING" | awk -F ';EntityPath=' '{print $2}') fi From d17c1834fe04221b60a8d03f49fcec11a75e4300 Mon Sep 17 00:00:00 2001 From: Kozimov Date: Thu, 7 Sep 2023 07:24:37 +0200 Subject: [PATCH 4/4] PCLOUDS-2709 Clean up --- deployment/dynatrace-azure-logs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/dynatrace-azure-logs.sh b/deployment/dynatrace-azure-logs.sh index 35d93f5..0c23552 100755 --- a/deployment/dynatrace-azure-logs.sh +++ b/deployment/dynatrace-azure-logs.sh @@ -384,7 +384,7 @@ if [[ "${DEPLOY_ACTIVEGATE}" == "false" ]]; then check_dynatrace_log_ingest_url fi -if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]] || [[ ]]; then +if [[ "$ENABLE_USER_ASSIGNED_MANAGED_IDENTITY" == "false" ]]; then EVENT_HUB_NAME=$(echo "$EVENT_HUB_CONNECTION_STRING" | awk -F ';EntityPath=' '{print $2}') fi