Skip to content

Commit

Permalink
resolve merge conflict and use 'az eventhubs eventhub show' to get ev…
Browse files Browse the repository at this point in the history
…ent hub id for role assignment

Signed-off-by: Jianguo Ma <jiangma@microsoft.com>
  • Loading branch information
majguo committed Dec 25, 2024
1 parent 2ce0110 commit cd4046a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/delete-azure-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# - RESOURCE_GROUP_NAME
# - APP_CONFIG_NAME
# - KEY_VAULT_NAME
# - EVENTHUBS_NAMESPACE

az appconfig delete --name "${APP_CONFIG_NAME}" --resource-group "${RESOURCE_GROUP_NAME}" --yes
az appconfig purge --name "${APP_CONFIG_NAME}" --yes
Expand Down
59 changes: 21 additions & 38 deletions .github/run-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,19 @@ STORAGE_ACCOUNT_RESOURCE_ID=$(az storage account show \
--query 'id' \
--output tsv)
# Assign the "Storage Blob Data Contributor" role to the current signed-in identity
servicePrincipal=$(az ad sp list --filter "appId eq '$AZURE_CLIENT_ID'" --query '[0].id' -o tsv)
OBJECT_ID=$(az ad sp list --filter "appId eq '$AZURE_CLIENT_ID'" --query '[0].id' -o tsv)
az role assignment create \
--assignee ${servicePrincipal} \
--assignee ${OBJECT_ID} \
--role "Storage Blob Data Contributor" \
--scope $STORAGE_ACCOUNT_RESOURCE_ID
# Get the connection string that has full access to the account
AZURE_STORAGE_BLOB_CONNECTION_STRING=$(az storage account show-connection-string \
--resource-group "${RESOURCE_GROUP_NAME}" \
--name "${STORAGE_ACCOUNT_NAME}" \
--query connectionString -o tsv)

# Run integration test with existing native executables against Azure services
mvn -f azure-storage-blob/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.storage.blob.endpoint=${AZURE_STORAGE_BLOB_ENDPOINT}
mvn -f azure-storage-blob/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.storage.blob.connection-string=${AZURE_STORAGE_BLOB_CONNECTION_STRING}

# Run both unit test and integration test in JVM mode against Azure services
mvn -f azure-storage-blob/pom.xml -B verify -Dazure.test=true -Dquarkus.azure.storage.blob.endpoint=${AZURE_STORAGE_BLOB_ENDPOINT}
mvn -f azure-storage-blob/pom.xml -B verify -Dazure.test=true -Dquarkus.azure.storage.blob.connection-string=${AZURE_STORAGE_BLOB_CONNECTION_STRING}
Expand Down Expand Up @@ -89,47 +87,32 @@ az cosmosdb sql role assignment create \
--account-name ${COSMOSDB_ACCOUNT_NAME} \
--resource-group ${RESOURCE_GROUP_NAME} \
--scope "/" \
--principal-id ${servicePrincipal} \
--principal-id ${OBJECT_ID} \
--role-definition-id 00000000-0000-0000-0000-000000000002

# Azure Event Hubs Extension
OBJECT_ID=$(az ad sp list --filter "appId eq '$AZURE_CLIENT_ID'" --query '[0].id' -o tsv)
az role assignment create \
--role "Azure Event Hubs Data Owner" \
--assignee-object-id ${OBJECT_ID} \
--scope "/subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP_NAME}/providers/Microsoft.EventHub/namespaces/${EVENTHUBS_NAMESPACE}"

export QUARKUS_AZURE_EVENTHUBS_NAMESPACE=${EVENTHUBS_NAMESPACE}
export QUARKUS_AZURE_EVENTHUBS_EVENTHUB_NAME=${EVENTHUBS_EVENTHUB_NAME}

# Run integration test with existing native executables against Azure services
mvn -B test-compile failsafe:integration-test -Dnative -Dazure.test=true

# Run both unit test and integration test in JVM mode against Azure services
mvn -B verify -Dazure.test=true

# Run integration test again for Azure Storage Blob Extension by using connection string for authentication
# Export the connection string that has full access to the account
export QUARKUS_AZURE_STORAGE_BLOB_CONNECTION_STRING=$(az storage account show-connection-string \
--resource-group "${RESOURCE_GROUP_NAME}" \
--name "${STORAGE_ACCOUNT_NAME}" \
--query connectionString -o tsv)
# Unset the endpoint environment variable
unset QUARKUS_AZURE_STORAGE_BLOB_ENDPOINT
cd azure-storage-blob
mvn -B test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -B verify -Dazure.test=true

# Run integration test again for Azure Cosmos Extension by using key for authentication
# Export the key that has full access to the account including management plane and data plane operations
export QUARKUS_AZURE_COSMOS_KEY=$(az cosmosdb keys list \
# Get the key that has full access to the account including management plane and data plane operations
AZURE_COSMOS_KEY=$(az cosmosdb keys list \
-n ${COSMOSDB_ACCOUNT_NAME} \
-g ${RESOURCE_GROUP_NAME} \
--query primaryMasterKey -o tsv)
mvn -f azure-cosmos/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-cosmos/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.cosmos.key=${AZURE_COSMOS_KEY}
mvn -f azure-cosmos/pom.xml -B verify -Dazure.test=true
mvn -f azure-cosmos/pom.xml -B verify -Dazure.test=true -Dquarkus.azure.cosmos.key=${AZURE_COSMOS_KEY}

# Azure Event Hubs Extension
# Retrieve the event hub resource ID
EVENTHUBS_EVENTHUB_RESOURCE_ID=$(az eventhubs eventhub show \
--resource-group $RESOURCE_GROUP_NAME \
--namespace-name $EVENTHUBS_NAMESPACE \
--name $EVENTHUBS_EVENTHUB_NAME \
--query 'id' \
--output tsv)
# Assign the "Azure Event Hubs Data Owner" role to the current signed-in identity
az role assignment create \
--role "Azure Event Hubs Data Owner" \
--assignee-object-id ${OBJECT_ID} \
--scope $EVENTHUBS_EVENTHUB_RESOURCE_ID
export QUARKUS_AZURE_EVENTHUBS_NAMESPACE=${EVENTHUBS_NAMESPACE}
export QUARKUS_AZURE_EVENTHUBS_EVENTHUB_NAME=${EVENTHUBS_EVENTHUB_NAME}
mvn -f azure-eventhubs/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-eventhubs/pom.xml -B verify -Dazure.test=true
8 changes: 7 additions & 1 deletion docs/modules/ROOT/pages/quarkus-azure-eventhubs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ Next, assign the `Azure Event Hubs Data Owner` role to the signed-in user, so th

[source,shell]
----
EVENTHUBS_EVENTHUB_RESOURCE_ID=$(az eventhubs eventhub show \
--resource-group rg-quarkus-azure-eventhubs \
--namespace-name ehnamespace20241217 \
--name eventhub1217 \
--query 'id' \
--output tsv)
az role assignment create \
--role "Azure Event Hubs Data Owner" \
--assignee-object-id ${OBJECT_ID} \
--scope "/subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/rg-quarkus-azure-eventhubs/providers/Microsoft.EventHub/namespaces/ehnamespace20241217"
--scope $EVENTHUBS_EVENTHUB_RESOURCE_ID
----

- Replace `${OBJECT_ID}` with the object ID of the signed-in user.
Expand Down
8 changes: 7 additions & 1 deletion integration-tests/azure-eventhubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ export QUARKUS_AZURE_EVENTHUBS_EVENTHUB_NAME=${EVENTHUBS_EVENTHUB_NAME}
Assign the `Azure Event Hubs Data Owner` role to the signed-in user as a Microsoft Entra identity, so that the sample application can do data plane operations.

```
EVENTHUBS_EVENTHUB_RESOURCE_ID=$(az eventhubs eventhub show \
--resource-group $RESOURCE_GROUP_NAME \
--namespace-name $EVENTHUBS_NAMESPACE \
--name $EVENTHUBS_EVENTHUB_NAME \
--query 'id' \
--output tsv)
az role assignment create \
--role "Azure Event Hubs Data Owner" \
--assignee-object-id ${servicePrincipal} \
--scope "/subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP_NAME}/providers/Microsoft.EventHub/namespaces/${EVENTHUBS_NAMESPACE}/eventhubs/${EVENTHUBS_EVENTHUB_NAME}"
--scope $EVENTHUBS_EVENTHUB_RESOURCE_ID
```


Expand Down

0 comments on commit cd4046a

Please sign in to comment.