Complete the code to initialize Dapr client in an Azure application.
from dapr.clients import DaprClient client = DaprClient() # Create a [1] client instance
The Dapr client is created by calling DaprClient() which initializes the client to interact with Dapr sidecar.
Complete the code to publish a message to a topic using Dapr in Azure.
client.publish_event(pubsub_name='[1]', topic='orders', data=b'order data')
The default pubsub component name is usually pubsub unless customized.
Fix the error in the code to retrieve a secret from Azure Key Vault using Dapr.
secret = client.get_secret(store_name='[1]', key='db-password')
The correct store name for Azure Key Vault in Dapr is azure-keyvault.
Fill both blanks to configure a Dapr state store and save state.
state_store = '[1]' client.save_state(store_name=state_store, key='user1', value=[2])
The state store name is typically 'statestore'. The value must be a Python dictionary, not a string.
Fill all three blanks to subscribe to a topic and handle events in a Dapr-enabled Azure app.
from dapr.ext.grpc import App app = App() @app.subscribe(pubsub_name='[1]', topic='[2]') def handle_event(data): print('Received:', [3])
The pubsub component is 'pubsub', the topic is 'orders', and the event handler prints the received data variable.