azure.storage.blob.changefeed package

class azure.storage.blob.changefeed.ChangeFeedClient(account_url: str, credential: Optional[Any] = None, **kwargs: Any)[source]

A client to interact with a specific account change feed.

Parameters
  • account_url (str) – The URI to the storage account.

  • credential – The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity. If the URL already has a SAS token, specifying an explicit credential will take priority.

Keyword Arguments

secondary_hostname (str) – The hostname of the secondary endpoint.

Example:

Creating the ChangeFeedClient from a URL to a public blob (no auth needed).
cf_client = ChangeFeedClient("https://{}.blob.core.windows.net".format(self.ACCOUNT_NAME),
                             credential=self.ACCOUNT_KEY)
classmethod from_connection_string(conn_str: str, credential: Optional[Any] = None, **kwargs: Any) → azure.storage.blob.changefeed._change_feed_client.ChangeFeedClient[source]

Create ChangeFeedClient from a Connection String.

Parameters
  • conn_str (str) – A connection string to an Azure Storage account.

  • credential – The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string, an account shared access key, or an instance of a TokenCredentials class from azure.identity. Credentials provided here will take precedence over those in the connection string.

Returns

A change feed client.

Return type

ChangeFeedClient

Example:

list_changes(**kwargs: Optional[datetime]) → ItemPaged[Dict][source]

Returns a generator to list the change feed events. The generator will lazily follow the continuation tokens returned by the service.

Keyword Arguments
  • start_time (datetime) – Filters the results to return only events which happened after this time.

  • end_time (datetime) – Filters the results to return only events which happened before this time.

  • results_per_page (int) – The page size when list events by page using by_page() method on the generator.

Returns

An iterable (auto-paging) response of events whose type is dictionary.

Return type

ItemPaged[dict]

Example:

List all change feed events.
cf_client = ChangeFeedClient("https://{}.blob.core.windows.net".format(self.ACCOUNT_NAME),
                             credential=self.ACCOUNT_KEY)
change_feed = cf_client.list_changes()

# print all events
for event in change_feed:
    print(event)
List change feed events by page.
# [START create_change_feed_client]
cf_client = ChangeFeedClient("https://{}.blob.core.windows.net".format(self.ACCOUNT_NAME),
                             credential=self.ACCOUNT_KEY)
# [END create_change_feed_client]

change_feed = cf_client.list_changes(results_per_page=10).by_page()

# print first page of events
change_feed_page1 = next(change_feed)
for event in change_feed_page1:
    print(event)

# print second page of events
change_feed_page2 = next(change_feed)
for event in change_feed_page2:
    print(event)