pull/116/head
Jen Looper 4 years ago
commit 2a3978594f

@ -264,7 +264,7 @@ The data will be saved as a JSON blob with the following format:
import json
import os
import uuid
from azure.storage.blob import BlobServiceClient
from azure.storage.blob import BlobServiceClient, PublicAccess
```
The `json` system module will be used to read and write JSON, the `os` system module will be used to read the connection string, the `uuid` system module will be used to generate a unique ID for the GPS reading.
@ -282,11 +282,13 @@ The data will be saved as a JSON blob with the following format:
if container.name == name:
return blob_service_client.get_container_client(container.name)
return blob_service_client.create_container(name)
return blob_service_client.create_container(name, public_access=PublicAccess.Container)
```
The Python blob SDK doesn't have a helper method to create a container if it doesn't exist. This code will load the connection string from the `local.settings.json` file (or the Application Settings once deployed to the cloud), then create a `BlobServiceClient` class from this to interact with the blob storage account. It then loops through all the containers for the blob storage account, looking for one with the provided name - if it finds one it will return a `ContainerClient` class that can interact with the container to create blobs. If it doesn't find one, then the container is created and the client for the new container is returned.
When the new container is created, public access is granted to query the blobs in the container. This will be used in the next lesson to visualize the GPS data on a map.
1. Unlike with soil moisture, with this code we want to store every event, so add the following code inside the `for event in events:` loop in the `main` function, below the `logging` statement:
```python

@ -5,7 +5,7 @@ import azure.functions as func
import json
import os
import uuid
from azure.storage.blob import BlobServiceClient
from azure.storage.blob import BlobServiceClient, PublicAccess
def get_or_create_container(name):
connection_str = os.environ['STORAGE_CONNECTION_STRING']
@ -15,7 +15,7 @@ def get_or_create_container(name):
if container.name == name:
return blob_service_client.get_container_client(container.name)
return blob_service_client.create_container(name)
return blob_service_client.create_container(name, public_access=PublicAccess.Container)
def main(events: List[func.EventHubEvent]):
for event in events:

@ -6,7 +6,7 @@ This video gives an overview of the Azure speech services, covering speech to te
[![Recognizing speech with a few lines of Python from Microsoft Build 2020](https://img.youtube.com/vi/h6xbpMPSGEA/0.jpg)](https://www.youtube.com/watch?v=h6xbpMPSGEA)
> 🎥 Click the image above to watch a video
> 🎥 Click the image above to watch the video
## Pre-lecture quiz
@ -129,7 +129,7 @@ One example is the [Microsoft Translator](https://www.microsoft.com/translator/a
[![Microsoft Translator live feature in action](https://img.youtube.com/vi/16yAGeP2FuM/0.jpg)](https://www.youtube.com/watch?v=16yAGeP2FuM)
> 🎥 Click the image above to watch a video
> 🎥 Click the image above to watch the video
Imagine having such a device available to you, especially when travelling or interacting with folks whose language you don't know. Having automatic translation devices in airports or hospitals would provide much needed accessibility improvements.

Loading…
Cancel
Save