1. Deploying AI-powered Azure Cognitive Search Services

    Python

    Azure Cognitive Search is a fully managed search-as-a-service in the cloud that provides a rich search experience over your content in web, mobile, and enterprise applications. To deploy Azure Cognitive Search service using Pulumi, you would typically need the following resources:

    1. Cognitive Services Account (azure-native.cognitiveservices.Account) - This account is used to create and manage Azure Cognitive Services on the Azure Platform, and is needed to deploy and use the Azure Cognitive Search service.

    2. Azure Search Service (azure-native.search.Service) - This is the main search service resource that provides access to the search capabilities and is the core resource for hosting your indexes, indexers, and other search artifacts.

    In the following program, we will create an Azure Cognitive Search service using the Python programming language with the Pulumi Azure Native Provider.

    First, you need to install the required Pulumi Azure Native package using pip if it's not already installed:

    pip install pulumi_azure_native

    Below is the Pulumi program that creates an Azure Cognitive Search service:

    import pulumi import pulumi_azure_native as azure_native # Create a resource group for the search service to reside in. resource_group = azure_native.resources.ResourceGroup('search-res-group') # Create an Azure Cognitive Search service with a basic free tier SKU. search_service = azure_native.search.Service('search-service', resource_group_name=resource_group.name, location=resource_group.location, sku=azure_native.search.SkuArgs( name="basic" # Sku can be "free", "basic", "standard", "standard2", or "storage_optimized_l1" based on your requirements ), identity=azure_native.search.IdentityArgs( type="SystemAssigned", # Enables an identity to be associated with the search service for RBAC purposes ), tags={ "Environment": "Dev" } ) # Export the primary and secondary admin keys of the search service admin_keys = pulumi.Output.all(resource_group.name, search_service.name).apply( lambda args: azure_native.search.list_admin_keys( resource_group_name=args[0], search_service_name=args[1] ) ) pulumi.export('search_service_name', search_service.name) pulumi.export('search_primary_admin_key', admin_keys.apply(lambda keys: keys.primary_key)) pulumi.export('search_secondary_admin_key', admin_keys.apply(lambda keys: keys.secondary_key))

    In this program:

    • We start by creating a new resource group to contain our Azure Cognitive Search service. Resource groups are a way to group Azure resources for management, billing, and access control.
    • Next, we create the Azure Search Service itself with a specified SKU. In this example, 'basic' is chosen, but you can choose another SKU that better suits your needs and pricing considerations.
    • We use the SystemAssigned identity, which provides the Search Service with an Azure Active Directory identity. This can be used to authenticate to other Azure services that support Azure AD authentication.
    • Finally, we export the Search Service name and the primary and secondary admin keys. These keys are needed to manage and access your Azure Cognitive Search service programmatically or via the Azure portal.

    The pulumi.export statements will output the service name, primary key, and secondary key to the console after the deployment, which you can then use in your application to interact with the Azure Cognitive Search Service.