Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Create and Execute Azure Stream Analytics Jobs on Windows

Azure Stream Analytics is a real-time analytics and complex event-processing engine that is designed to analyze and process high volumes of fast streaming data from multiple sources simultaneously. This article will guide you through the process of creating and executing Azure Stream Analytics jobs using the Windows environment.

Prerequisites

Before you begin, ensure you have the following:

  1. An active Azure subscription.
  2. Azure CLI installed on your Windows machine.
  3. PowerShell installed on your Windows machine.

Step 1: Install Azure CLI

If you haven't installed Azure CLI, you can do so by following these steps:

  1. Open PowerShell as an administrator.
  2. Execute the following command:
    Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -ArgumentList '/I AzureCLI.msi /quiet' -Wait; Remove-Item .\AzureCLI.msi

Step 2: Log in to Azure

Once Azure CLI is installed, you need to log in to your Azure account:

  1. Open PowerShell.
  2. Execute the following command:
    az login

    This will open a web browser window for you to log in with your Azure credentials.

Step 3: Create a Resource Group

A resource group is a container that holds related resources for an Azure solution. Create a resource group using the following command:

az group create --name MyResourceGroup --location eastus

Step 4: Create an Azure Stream Analytics Job

Now, create a Stream Analytics job using the following command:

az stream-analytics job create --name MyStreamAnalyticsJob --resource-group MyResourceGroup --location eastus --output-error-policy Stop

Step 5: Define Input and Output

Define the input source (e.g., Azure Event Hub) and output sink (e.g., Azure SQL Database) for your Stream Analytics job.

Create Input

az stream-analytics input create --job-name MyStreamAnalyticsJob --name MyInput --resource-group MyResourceGroup --type Stream --datasource EventHub --event-hub-namespace MyEventHubNamespace --event-hub-name MyEventHub --consumer-group $Default --shared-access-policy-name RootManageSharedAccessKey --shared-access-policy-key <YourAccessKey>

Create Output

az stream-analytics output create --job-name MyStreamAnalyticsJob --name MyOutput --resource-group MyResourceGroup --datasource SQL --server MySqlServer.database.windows.net --database MyDatabase --table MyTable --user MyUser --password <YourPassword>

Step 6: Define the Query

Define the query that processes the input data and sends the results to the output:

az stream-analytics transformation create --job-name MyStreamAnalyticsJob --resource-group MyResourceGroup --name MyTransformation --streaming-units 1 --query "SELECT * INTO MyOutput FROM MyInput"

Step 7: Start the Job

Finally, start the Stream Analytics job:

az stream-analytics job start --name MyStreamAnalyticsJob --resource-group MyResourceGroup

Conclusion

You have successfully created and executed an Azure Stream Analytics job using the Windows environment. This guide covered the installation of Azure CLI, logging into Azure, creating a resource group, defining input and output, setting up the query, and starting the job.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.