0
0
Azurecloud~10 mins

Dapr integration overview in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Dapr client in an Azure application.

Azure
from dapr.clients import DaprClient
client = DaprClient()  # Create a [1] client instance
Drag options to blanks, or click blank then click option'
ACloud
BAzure
CDapr
DService
Attempts:
3 left
💡 Hint
Common Mistakes
Using Azure or Service instead of Dapr as the client class.
Not creating a client instance before use.
2fill in blank
medium

Complete the code to publish a message to a topic using Dapr in Azure.

Azure
client.publish_event(pubsub_name='[1]', topic='orders', data=b'order data')
Drag options to blanks, or click blank then click option'
Apubsub
Bazure-pubsub
Cazure-servicebus
Deventbus
Attempts:
3 left
💡 Hint
Common Mistakes
Using Azure-specific names instead of the configured pubsub component name.
Confusing topic name with pubsub name.
3fill in blank
hard

Fix the error in the code to retrieve a secret from Azure Key Vault using Dapr.

Azure
secret = client.get_secret(store_name='[1]', key='db-password')
Drag options to blanks, or click blank then click option'
Aazure-keyvault
Bkeyvault
Cazurekeyvault
Dkeyvaultstore
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'azurekeyvault' without hyphen.
Using generic names like 'keyvaultstore'.
4fill in blank
hard

Fill both blanks to configure a Dapr state store and save state.

Azure
state_store = '[1]'
client.save_state(store_name=state_store, key='user1', value=[2])
Drag options to blanks, or click blank then click option'
Astatestore
B'{"name": "Alice"}'
C{"name": "Alice"}
Dblobstore
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'blobstore' instead of 'statestore' as store name.
Passing JSON string instead of dictionary for value.
5fill in blank
hard

Fill all three blanks to subscribe to a topic and handle events in a Dapr-enabled Azure app.

Azure
from dapr.ext.grpc import App
app = App()

@app.subscribe(pubsub_name='[1]', topic='[2]')
def handle_event(data):
    print('Received:', [3])
Drag options to blanks, or click blank then click option'
Apubsub
Borders
Cdata
Deventbus
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong pubsub component name.
Using wrong topic name.
Printing undefined variable instead of 'data'.