|
| 1 | +--- |
| 2 | +page_type: sample |
| 3 | +languages: |
| 4 | +- python |
| 5 | +products: |
| 6 | +- azure |
| 7 | +description: "These code samples will show you how to manage Communication Service resources using Azure SDK for Python." |
| 8 | +urlFragment: communication |
| 9 | +--- |
| 10 | + |
| 11 | +# Getting started - Managing Azure Communication Services using Azure Python SDK |
| 12 | + |
| 13 | +These code samples will show you how to manage Communication Service resources using Azure SDK for Python. |
| 14 | + |
| 15 | +## Features |
| 16 | + |
| 17 | +This project framework provides examples for the following services: |
| 18 | + |
| 19 | +### Communication |
| 20 | + |
| 21 | +* Using the Azure SDK for Python - Communication Management Library [azure-mgmt-communication](https://pypi.org/project/azure-mgmt-communication/) for the [Azure Communication API](https://docs.microsoft.com/en-us/rest/api/communication/) |
| 22 | + |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +1. Before we run the samples, we need to make sure we have setup the credentials. Follow the instructions in |
| 28 | + [register a new application using Azure |
| 29 | + portal](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal) |
| 30 | + to obtain `subscription id`,`client id`,`client secret`, and `application id` |
| 31 | + |
| 32 | +2. Store your credentials an environment variables. |
| 33 | +For example, in Linux-based OS, you can do |
| 34 | + |
| 35 | +```bash |
| 36 | +export AZURE_TENANT_ID="xxx" |
| 37 | +export AZURE_CLIENT_ID="xxx" |
| 38 | +export AZURE_CLIENT_SECRET="xxx" |
| 39 | +export AZURE_SUBSCRIPTION_ID="xxx" |
| 40 | +export AZURE_NOTIFICATION_HUB_ID="xxx" |
| 41 | +export AZURE_NOTIFICATION_HUB_CONNECTION_STRING="xxx" |
| 42 | +``` |
| 43 | + |
| 44 | +### Installation |
| 45 | + |
| 46 | +1. If you don't already have it, [install Python](https://www.python.org/downloads/). |
| 47 | + |
| 48 | + This sample (and the SDK) is compatible with Python 2.7, 3.3, 3.4, 3.5 and 3.6. |
| 49 | + |
| 50 | +2. General recommendation for Python development is to use a Virtual Environment. |
| 51 | + For more information, see https://docs.python.org/3/tutorial/venv.html |
| 52 | + |
| 53 | + Install and initialize the virtual environment with the "venv" module on Python 3 (you must install |
| 54 | + [virtualenv](https://pypi.python.org/pypi/virtualenv) for Python 2.7): |
| 55 | + |
| 56 | + ``` |
| 57 | + python -m venv mytestenv # Might be "python3" or "py -3.6" depending on your Python installation |
| 58 | + cd mytestenv |
| 59 | + source bin/activate # Linux shell (Bash, ZSH, etc.) only |
| 60 | + ./scripts/activate # PowerShell only |
| 61 | + ./scripts/activate.bat # Windows CMD only |
| 62 | + ``` |
| 63 | +
|
| 64 | +### Quickstart |
| 65 | +
|
| 66 | +1. Clone the repository. |
| 67 | +
|
| 68 | + ``` |
| 69 | + git clone https://github.com/Azure-Samples/azure-samples-python-management.git |
| 70 | + ``` |
| 71 | +
|
| 72 | +2. Install the dependencies using pip. |
| 73 | +
|
| 74 | + ``` |
| 75 | + cd azure-samples-python-management/samples/communication |
| 76 | + pip install -r requirements.txt |
| 77 | + ``` |
| 78 | +
|
| 79 | +## Demo |
| 80 | +
|
| 81 | +A demo app is included to show how to use the project. This app covers the following scenarios: |
| 82 | +
|
| 83 | +- Create a Communication Service |
| 84 | +- Fetch a Communication Service |
| 85 | +- Update a Communication Service |
| 86 | +- Delete a Communication Service |
| 87 | +- List all Communication Services in the subscription |
| 88 | +- List all Communication Services in the resource group |
| 89 | +- List the Primary and Secondary key pairs |
| 90 | +- Regenerate the Primary or Secondary key pair |
| 91 | +- Link a Notification Hub to the Communication Service |
| 92 | +
|
| 93 | +To view all available commands for the demo, execute `python manage_communication.py -h` |
| 94 | +
|
| 95 | +To run the complete demo, execute `python manage_communication.py all` |
| 96 | +
|
| 97 | +The sample files do not have dependency each other and each file represents an individual end-to-end scenario. |
| 98 | +Please look at the sample that contains the scenario you are interested in |
| 99 | +
|
| 100 | +## Resources |
| 101 | +
|
| 102 | +- https://github.com/Azure/azure-sdk-for-python |
0 commit comments