From 660f5921b69da0521e4f6bfa47ad484daa4240b8 Mon Sep 17 00:00:00 2001 From: Jim Bennett Date: Mon, 21 Jun 2021 15:35:43 -0700 Subject: [PATCH] Public containers (#113) * Adding content * Update en.json * Update README.md * Update TRANSLATIONS.md * Adding lesson tempolates * Fixing code files with each others code in * Update README.md * Adding lesson 16 * Adding virtual camera * Adding Wio Terminal camera capture * Adding wio terminal code * Adding SBC classification to lesson 16 * Adding challenge, review and assignment * Adding images and using new Azure icons * Update README.md * Update iot-reference-architecture.png * Adding structure for JulyOT links * Removing icons * Sketchnotes! * Create lesson-1.png * Starting on lesson 18 * Updated sketch * Adding virtual distance sensor * Adding Wio Terminal image classification * Update README.md * Adding structure for project 6 and wio terminal distance sensor * Adding some of the smart timer stuff * Updating sketchnotes * Adding virtual device speech to text * Adding chapter 21 * Language tweaks * Lesson 22 stuff * Update en.json * Bumping seeed libraries * Adding functions lab to lesson 22 * Almost done with LUIS * Update README.md * Reverting sunlight sensor change Fixes #88 * Structure * Adding speech to text lab for Pi * Adding virtual device text to speech lab * Finishing lesson 23 * Clarifying privacy Fixes #99 * Update README.md * Update hardware.md * Update README.md * Fixing some code samples that were wrong * Adding more on translation * Adding more on translator * Update README.md * Update README.md * Adding public access to the container --- 3-transport/lessons/2-store-location-data/README.md | 6 ++++-- .../code/functions/gps-trigger/iot-hub-trigger/__init__.py | 4 ++-- 6-consumer/lessons/4-multiple-language-support/README.md | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/3-transport/lessons/2-store-location-data/README.md b/3-transport/lessons/2-store-location-data/README.md index 562fc7d..8044fe0 100644 --- a/3-transport/lessons/2-store-location-data/README.md +++ b/3-transport/lessons/2-store-location-data/README.md @@ -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 diff --git a/3-transport/lessons/2-store-location-data/code/functions/gps-trigger/iot-hub-trigger/__init__.py b/3-transport/lessons/2-store-location-data/code/functions/gps-trigger/iot-hub-trigger/__init__.py index d908e88..eb4a0a3 100644 --- a/3-transport/lessons/2-store-location-data/code/functions/gps-trigger/iot-hub-trigger/__init__.py +++ b/3-transport/lessons/2-store-location-data/code/functions/gps-trigger/iot-hub-trigger/__init__.py @@ -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: diff --git a/6-consumer/lessons/4-multiple-language-support/README.md b/6-consumer/lessons/4-multiple-language-support/README.md index 7a6bf1d..9fb0a0d 100644 --- a/6-consumer/lessons/4-multiple-language-support/README.md +++ b/6-consumer/lessons/4-multiple-language-support/README.md @@ -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.