From 884a3d4a57e6d689344b9c7b5b871b9395022d5c Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Thu, 8 May 2025 15:33:10 -0700 Subject: [PATCH 01/10] Adding data collection disclosure to readme --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 9f925bb43daa..e8c02080a09d 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,40 @@ Management libraries can be identified by namespaces that start with `azure-mgmt * File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-python/issues) * Check [previous questions](https://stackoverflow.com/questions/tagged/azure+python) or ask new ones on StackOverflow using `azure` and `python` tags. + +## Data Collection +The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described below. You can learn more about data collection and use in the help documentation and Microsoft’s [privacy statement](https://go.microsoft.com/fwlink/?LinkID=824704). For more information on the data collected by the Azure SDK, please visit the [Telemetry Guidelines](https://azure.github.io/azure-sdk/general_azurecore.html#telemetry-policy) page. + +### Telemetry Configuration +Telemetry collection is on by default. + +To opt out, you can disable telemetry at client construction. Set `user_agent_policy` to `None` during creation. This will disable telemetry for all methods in the client. Do this for every new client. + +The example below uses the `azure-storage-blob` package. In your code, you can replace `azure-storage-blob` with the package you are using. + +```python +import os +from azure.identity import ManagedIdentityCredential +from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient +from azure.core.pipeline.policies import UserAgentPolicy + +try: + # Create your credential you want to use + credential = ManagedIdentityCredential() + + account_url = "https://.blob.core.windows.net" + # Create the BlobServiceClient object + blob_service_client = BlobServiceClient(account_url, credential=default_credential, user_agent_policy=None) + + download_file_path = os.path.join(local_path, str.replace(local_file_name ,'.txt', 'DOWNLOAD.txt')) + container_client = blob_service_client.get_container_client(container= container_name) + # TODO: do something with the container client like download blob to a file + +except Exception as ex: + print('Exception:') + print(ex) +``` + ### Reporting security issues and security bugs Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) . You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://www.microsoft.com/msrc/faqs-report-an-issue). From 3fcb1641b7a45f0305e3aa0e2f0570ea4a7021a0 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Thu, 8 May 2025 16:07:20 -0700 Subject: [PATCH 02/10] fixing credential name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8c02080a09d..11c5ae5220ea 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,11 @@ from azure.core.pipeline.policies import UserAgentPolicy try: # Create your credential you want to use - credential = ManagedIdentityCredential() + mi_credential = ManagedIdentityCredential() account_url = "https://.blob.core.windows.net" # Create the BlobServiceClient object - blob_service_client = BlobServiceClient(account_url, credential=default_credential, user_agent_policy=None) + blob_service_client = BlobServiceClient(account_url, credential=mi_credential, user_agent_policy=None) download_file_path = os.path.join(local_path, str.replace(local_file_name ,'.txt', 'DOWNLOAD.txt')) container_client = blob_service_client.get_container_client(container= container_name) From 95ca25428af7c16b75eac0ec5255d315fd12bf56 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Thu, 8 May 2025 16:09:21 -0700 Subject: [PATCH 03/10] updaing code samples --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 11c5ae5220ea..c805968eb3b8 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,7 @@ try: # Create the BlobServiceClient object blob_service_client = BlobServiceClient(account_url, credential=mi_credential, user_agent_policy=None) - download_file_path = os.path.join(local_path, str.replace(local_file_name ,'.txt', 'DOWNLOAD.txt')) - container_client = blob_service_client.get_container_client(container= container_name) + container_client = blob_service_client.get_container_client(container=) # TODO: do something with the container client like download blob to a file except Exception as ex: From 2b61fb5ccd6e812e2922c40449adf66e33f3eb64 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Fri, 9 May 2025 14:05:41 -0700 Subject: [PATCH 04/10] incorporating pauls suggestion --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c805968eb3b8..21365aeb74c0 100644 --- a/README.md +++ b/README.md @@ -68,14 +68,21 @@ import os from azure.identity import ManagedIdentityCredential from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient from azure.core.pipeline.policies import UserAgentPolicy +from azure.core.pipeline.policies import UserAgentPolicy try: # Create your credential you want to use mi_credential = ManagedIdentityCredential() account_url = "https://.blob.core.windows.net" + + # Setup user-agent override + class NoUserAgentPolicy(UserAgentPolicy): + def on_request(self, request): + pass + # Create the BlobServiceClient object - blob_service_client = BlobServiceClient(account_url, credential=mi_credential, user_agent_policy=None) + blob_service_client = BlobServiceClient(account_url, credential=mi_credential, user_agent_policy=NoUserAgentPolicy()) container_client = blob_service_client.get_container_client(container=) # TODO: do something with the container client like download blob to a file From f15c3e241bfc2be01a45b4e8e6ed324892b8fe5f Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Mon, 12 May 2025 17:18:58 -0700 Subject: [PATCH 05/10] removing double import Co-authored-by: Krista Pratico --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 21365aeb74c0..b948fbaade8c 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,6 @@ import os from azure.identity import ManagedIdentityCredential from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient from azure.core.pipeline.policies import UserAgentPolicy -from azure.core.pipeline.policies import UserAgentPolicy try: # Create your credential you want to use From d7405313168079304cd2cbdcb4eab3330b5efc32 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Mon, 12 May 2025 17:19:18 -0700 Subject: [PATCH 06/10] correcting tabs Co-authored-by: Krista Pratico --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b948fbaade8c..aa7d71622196 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,8 @@ try: # Setup user-agent override class NoUserAgentPolicy(UserAgentPolicy): - def on_request(self, request): - pass + def on_request(self, request): + pass # Create the BlobServiceClient object blob_service_client = BlobServiceClient(account_url, credential=mi_credential, user_agent_policy=NoUserAgentPolicy()) From e7f786c8f0d8fd9e05f8e3df6d816dabce8b39e4 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Mon, 12 May 2025 17:28:44 -0700 Subject: [PATCH 07/10] updating description and removing try catch --- README.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index aa7d71622196..c0b825969deb 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The software may collect information about you and your use of the software and ### Telemetry Configuration Telemetry collection is on by default. -To opt out, you can disable telemetry at client construction. Set `user_agent_policy` to `None` during creation. This will disable telemetry for all methods in the client. Do this for every new client. +To opt out, you can disable telemetry at client construction. Define a `NoUserAgentPolicy` class that is a subclass of `UserAgentPolicy` with an `on_request` method that does nothing. Then pass this as kwargs `user_agent_policy=NoUserAgentPolicy` during client creation. This will disable telemetry for all methods in the client. Do this for every new client. The example below uses the `azure-storage-blob` package. In your code, you can replace `azure-storage-blob` with the package you are using. @@ -69,26 +69,22 @@ from azure.identity import ManagedIdentityCredential from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient from azure.core.pipeline.policies import UserAgentPolicy -try: - # Create your credential you want to use - mi_credential = ManagedIdentityCredential() - account_url = "https://.blob.core.windows.net" +# Create your credential you want to use +mi_credential = ManagedIdentityCredential() - # Setup user-agent override - class NoUserAgentPolicy(UserAgentPolicy): - def on_request(self, request): - pass +account_url = "https://.blob.core.windows.net" - # Create the BlobServiceClient object - blob_service_client = BlobServiceClient(account_url, credential=mi_credential, user_agent_policy=NoUserAgentPolicy()) +# Setup user-agent override +class NoUserAgentPolicy(UserAgentPolicy): + def on_request(self, request): + pass - container_client = blob_service_client.get_container_client(container=) - # TODO: do something with the container client like download blob to a file +# Create the BlobServiceClient object +blob_service_client = BlobServiceClient(account_url, credential=mi_credential, user_agent_policy=NoUserAgentPolicy()) -except Exception as ex: - print('Exception:') - print(ex) +container_client = blob_service_client.get_container_client(container=) +# TODO: do something with the container client like download blob to a file ``` ### Reporting security issues and security bugs From e3fb788e2a36814ecd00a4d4f0861b576edee632 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Mon, 12 May 2025 17:31:08 -0700 Subject: [PATCH 08/10] added missing new instance --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0b825969deb..5feaba3d3c81 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The software may collect information about you and your use of the software and ### Telemetry Configuration Telemetry collection is on by default. -To opt out, you can disable telemetry at client construction. Define a `NoUserAgentPolicy` class that is a subclass of `UserAgentPolicy` with an `on_request` method that does nothing. Then pass this as kwargs `user_agent_policy=NoUserAgentPolicy` during client creation. This will disable telemetry for all methods in the client. Do this for every new client. +To opt out, you can disable telemetry at client construction. Define a `NoUserAgentPolicy` class that is a subclass of `UserAgentPolicy` with an `on_request` method that does nothing. Then pass instance of this class as kwargs `user_agent_policy=NoUserAgentPolicy()` during client creation. This will disable telemetry for all methods in the client. Do this for every new client. The example below uses the `azure-storage-blob` package. In your code, you can replace `azure-storage-blob` with the package you are using. From 229c37a35e4b2fedc5dc637c10a89180686ab87f Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Tue, 13 May 2025 14:55:35 -0700 Subject: [PATCH 09/10] updating import Co-authored-by: Paul Van Eck --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5feaba3d3c81..e331e98787d8 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ The example below uses the `azure-storage-blob` package. In your code, you can r ```python import os from azure.identity import ManagedIdentityCredential -from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient +from azure.storage.blob import BlobServiceClient from azure.core.pipeline.policies import UserAgentPolicy From eeb649eb57e2dcc51e05f82f215e8898485f5bd1 Mon Sep 17 00:00:00 2001 From: Sandeep Sen Date: Tue, 13 May 2025 15:40:56 -0700 Subject: [PATCH 10/10] update typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: McCoy Patiño <39780829+mccoyp@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e331e98787d8..015f0f32728a 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ mi_credential = ManagedIdentityCredential() account_url = "https://.blob.core.windows.net" -# Setup user-agent override +# Set up user-agent override class NoUserAgentPolicy(UserAgentPolicy): def on_request(self, request): pass