0
votes

I created an Azure Function which is triggered by Azure Service Bus Queue. I deployed the functions through the Azure Pipeline in Azure also.

My questions are:

  1. I can create the queues manually in Azure Portal. But how can I create the Azure Service Bus Queue during the Build and Release pipeline?
  2. I can add an App Configuration (Service Bus Connection String) manually for the Azure Function. But how can I add that during the build and release pipeline?

Azure Pipeline Tasks:

enter image description here

1

1 Answers

2
votes

There is many tasks in Release Pipeline you can use to create Azure Service Bus Queue:

  • Azure CLI
  • PowerShell
  • ARM template deployment
  • Terraform

Azure CLI or PowerShell could solve yours problems, you just must authorize in script and use any command you like to use - create Azure Service Bus and set configuration to Azure Functions.

There is example in CLI:

  1. Create Azure Service Bus Queue (from documentation)

    # Create a resource group
    resourceGroupName="myResourceGroup"
    
    az group create --name $resourceGroupName --location eastus
    
    # Create a Service Bus messaging namespace with a unique name
    namespaceName=myNameSpace$RANDOM
    az servicebus namespace create --resource-group $resourceGroupName --name $namespaceName --location eastus
    
    # Create a Service Bus queue
    az servicebus queue create --resource-group $resourceGroupName --namespace-name $namespaceName --name BasicQueue
    
    # Get the connection string for the namespace
    connectionString=$(az servicebus namespace authorization-rule keys list --resource-group $resourceGroupName --namespace-name $namespaceName --name RootManageSharedAccessKey --query primaryConnectionString --output tsv)
    
  2. Set settings to Azure Functions (from documentation)

    az functionapp config appsettings set --name <FUNCTION_APP_NAME> \
    --resource-group <RESOURCE_GROUP_NAME> \
    --settings CUSTOM_FUNCTION_APP_SETTING=12345