Skip to content

Commit ff54872

Browse files
committed
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-python into regenerate_certs
* 'master' of https://github.com/Azure/azure-sdk-for-python: [text analytics] remove duplicate platform info in user agent (Azure#12123) [form recognizer] remove duplicate platform info in user agent (Azure#12124) fix broken links (Azure#12100) Document "<unchanged>" for DataSourceCredentials.connectionString if it is empty (Azure#12129) Let the transport handles bad urls (Azure#12106) Remove Unneeded Reference to repository resource (Azure#11929) enable logging for tests (Azure#12110) fix network in batch testcase (Azure#12114) update test recording for appservice (Azure#12116) Add test for connection monitor and fix test api version. (Azure#12113) Minor root readme and mgmt quickstart update for Track 2 mgmt sdk (Azure#12112) Quickstart for Track 2 preview management libraries and update root readme for track 2 (Azure#11384) Seg fault fix (Azure#11933)
2 parents 4dd7ee4 + 4fef4d7 commit ff54872

File tree

471 files changed

+3800
-4486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

471 files changed

+3800
-4486
lines changed

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ The client libraries are supported on Python 2.7 and 3.5.3 or later.
1919
Each service might have a number of libraries available from each of the following categories:
2020
* [Client - New Releases](#Client-New-Releases)
2121
* [Client - Previous Versions](#Client-Previous-Versions)
22-
* [Management](#Management)
22+
* [Management - New Releases](#Management-New-Releases)
23+
* [Management - Previous Versions](#Management-Previous-Versions)
2324

2425
### Client: New Releases
2526

@@ -33,9 +34,15 @@ You can find the [most up to date list of all of the new packages on our page](h
3334

3435
Last stable versions of packages that have been provided for usage with Azure and are production-ready. These libraries provide you with similar functionalities to the Preview ones as they allow you to use and consume existing resources and interact with them, for example: upload a blob. They might not implement the [guidelines](https://azure.github.io/azure-sdk/python_introduction.html) or have the same feature set as the Novemeber releases. They do however offer wider coverage of services.
3536

36-
### Management
37+
### Management: New Releases
38+
A new set of management libraries that follow the [Azure SDK Design Guidelines for Python](https://azure.github.io/azure-sdk/python/guidelines/) are now in Public Preview. These new libraries provide a number of core capabilities that are shared amongst all Azure SDKs, including the intuitive Azure Identity library, an HTTP Pipeline with custom policies, error-handling, distributed tracing, and much more.
39+
You can find the list of new packages [on this page](https://azure.github.io/azure-sdk/releases/latest/python.html). Documentation and for these new libraries can be found [here](https://azure.github.io/azure-sdk-for-python). Code samples can also be viewed [here](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing)
3740

38-
Libraries which enable you to provision specific resources. They are responsible for directly mirroring and consuming Azure service's REST endpoints. The management libraries use the `azure-mgmt-<service name>` convention for their package names.
41+
> NOTE: If you need to ensure your code is ready for production use one of the stable, non-preview libraries.
42+
43+
### Management: Previous Versions
44+
For a complete list of management libraries which enable you to provision and manage Azure resources, please check [here](https://azure.github.io/azure-sdk/releases/latest/all/python.html). They might not have the same feature set as the new releases but they do offer wider coverage of services.
45+
Management libraries can be identified by namespaces that start with `azure-mgmt-`, e.g. `azure-mgmt-compute`
3946

4047
## Need help?
4148

doc/sphinx/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ section of the project.
6565

6666
installation
6767
quickstart_authentication
68+
mgmt_preview_quickstart
6869
multicloud
6970
exceptions
7071
Service Management (Legacy) <servicemanagement>
+267
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
Quickstart Tutorial - Resource Management (Preview Libraries)
2+
===============================================================
3+
4+
We are excited to announce that a new set of management libraries are now in Public Preview.
5+
Those packages share a number of new features such as Azure Identity support,
6+
HTTP pipeline, error-handling.,etc, and they also follow the new Azure SDK guidelines which
7+
create easy-to-use APIs that are idiomatic, compatible, and dependable.
8+
9+
You can find the details of those new libraries `here <https://azure.github.io/azure-sdk/releases/latest/#python>`__
10+
11+
In this basic quickstart guide, we will walk you through how to
12+
authenticate to Azure using the preview libraries and start interacting with
13+
Azure resources. There are several possible approaches to
14+
authentication. This document illustrates the most common scenario
15+
16+
Prerequisites
17+
-------------
18+
19+
| You will need the following values to authenticate to Azure
20+
21+
- **Subscription ID**
22+
- **Client ID**
23+
- **Client Secret**
24+
- **Tenant ID**
25+
26+
These values can be obtained from the portal, here's the instructions:
27+
28+
Get Subscription ID
29+
^^^^^^^^^^^^^^^^^^^
30+
31+
1. Login into your Azure account
32+
2. Select Subscriptions in the left sidebar
33+
3. Select whichever subscription is needed
34+
4. Click on Overview
35+
5. Copy the Subscription ID
36+
37+
Get Client ID / Client Secret / Tenant ID
38+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39+
40+
For information on how to get Client ID, Client Secret, and Tenant ID, please refer to `this document <https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal>`__
41+
42+
Setting Environment Variables
43+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44+
45+
After you obtained the values, you need to set the following values as
46+
your environment variables
47+
48+
- ``AZURE_CLIENT_ID``
49+
- ``AZURE_CLIENT_SECRET``
50+
- ``AZURE_TENANT_ID``
51+
- ``AZURE_SUBSCRIPTION_ID``
52+
53+
To set the following environment variables on your development system:
54+
55+
Windows (Note: Administrator access is required)
56+
57+
1. Open the Control Panel
58+
2. Click System Security, then System
59+
3. Click Advanced system settings on the left
60+
4. Inside the System Properties window, click the Environment Variables… button.
61+
5. Click on the property you would like to change, then click the Edit… button. If the property name is not listed, then click the New… button.
62+
63+
Linux-based OS
64+
::
65+
66+
export AZURE_CLIENT_ID="__CLIENT_ID__"
67+
export AZURE_CLIENT_SECRET="__CLIENT_SECRET__"
68+
export AZURE_TENANT_ID="__TENANT_ID__"
69+
export AZURE_SUBSCRIPTION_ID="__SUBSCRIPTION_ID__"
70+
71+
Authentication and Creating Management Client
72+
------------------------------------------------------
73+
74+
Now that the environment is setup, all you need to do is to create an
75+
authenticated client. Our default option is to use
76+
**DefaultAzureCredential** and in this guide we have picked
77+
**Resources** as our target service, but you can set it up similarly for any other service that you are using.
78+
79+
To authenticate to Azure and create
80+
a management client, simply do the following:
81+
82+
::
83+
84+
import azure.mgmt.resource
85+
import azure.mgmt.network
86+
from azure.identity import DefaultAzureCredential
87+
...
88+
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID")
89+
credential = DefaultAzureCredential()
90+
resource_client = azure.mgmt.resource.ResourceManagementClient(credential=credential, subscription_id=subscription_id)
91+
network_client = azure.mgmt.network.NetworkManagementClient(credential=credential, subscription_id=subscription_id)
92+
93+
More information and different authentication approaches using Azure Identity can be found in
94+
`this document <https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python>`__
95+
96+
Managing Resources
97+
------------------
98+
99+
Now that we are authenticated, we can use the Resource client (azure.mgmt.resource.ResourceManagementClient) we have created to perform operations on Resource Group. In this example, we will show to manage Resource Groups.
100+
101+
**Create a resource group**
102+
103+
::
104+
105+
location = "westus2"
106+
group_name = "my_resource_group_name"
107+
group = resource_client.resource_groups.create_or_update(
108+
group_name,
109+
{'location': location}
110+
)
111+
112+
**Update a resource group**
113+
114+
::
115+
116+
group_name = "my_resource_group_name"
117+
group.tags = {
118+
"environment":"test",
119+
"department":"tech"
120+
}
121+
updated_group = resource_client.resource_groups.create_or_update(group_name, group)
122+
123+
**List all resource groups**
124+
125+
::
126+
127+
group_list = self.resource_client.resource_groups.list()
128+
for g in group_list:
129+
print_resource_group(g)
130+
131+
**Delete a resource group**
132+
133+
::
134+
135+
delete_async_op = resource_client.resource_groups.begin_delete(group_name)
136+
delete_async_op.wait()
137+
138+
Managing Network
139+
------------------
140+
We can use the Network client (azure.mgmt.resource.NetworkManagementClient) we have created to perform operations on Network related resources. In this example, we will show how to manage Public IP Addresses.
141+
142+
**Create a Network Public IP Address**
143+
144+
::
145+
146+
GROUP_NAME = "testgroup"
147+
PUBLIC_IP_ADDRESS = "public_ip_address_name"
148+
149+
# Create Resource Group
150+
resource_client.resource_groups.create_or_update(
151+
GROUP_NAME,
152+
{"location": "eastus"}
153+
)
154+
155+
# Create Public IP Address
156+
public_ip_address = network_client.public_ip_addresses.begin_create_or_update(
157+
GROUP_NAME,
158+
PUBLIC_IP_ADDRESS,
159+
{
160+
"location": "eastus"
161+
}
162+
).result()
163+
print("Create Public IP Address:\n{}".format(public_ip_address))
164+
165+
**Get a Network Public IP Address**
166+
167+
::
168+
169+
public_ip_address = network_client.public_ip_addresses.get(
170+
GROUP_NAME,
171+
PUBLIC_IP_ADDRESS
172+
)
173+
print("Get Public IP Address:\n{}".format(public_ip_address))
174+
175+
**Update tags in Network Public IP Address**
176+
177+
::
178+
179+
# Update Public IP Address
180+
public_ip_address = network_client.public_ip_addresses.update_tags(
181+
GROUP_NAME,
182+
PUBLIC_IP_ADDRESS,
183+
{
184+
"tags": {
185+
"tag1": "value1",
186+
"tag2": "value2"
187+
}
188+
}
189+
)
190+
print("Updated Public IP Address \n{}".format(public_ip_address))
191+
192+
**Delete a Network Public IP Address**
193+
194+
::
195+
196+
# Delete Public IP Address
197+
public_ip_address = network_client.public_ip_addresses.begin_delete(
198+
GROUP_NAME,
199+
PUBLIC_IP_ADDRESS
200+
).result()
201+
print("Delete Public IP Address.\n")
202+
203+
Async and sync operations
204+
-------------------------
205+
In python>=3.5, Azure Python SDK provides the choice for user to use the asynchronous client for asynchronous programming.
206+
207+
Note that asyncio in Windows is underpowered and please take caution when using async operations on Windows systems
208+
209+
**Create Async Management Client**
210+
::
211+
212+
from azure.identity.aio import DefaultAzureCredential
213+
from azure.mgmt.network.aio import NetworkManagementClient
214+
from azure.mgmt.resource.resources.aio import ResourceManagementClient
215+
216+
SUBSCRIPTION_ID = os.environ.get("SUBSCRIPTION_ID", None)
217+
credential = DefaultAzureCredential()
218+
resource_client = ResourceManagementClient(
219+
credential=credential,
220+
subscription_id=SUBSCRIPTION_ID
221+
)
222+
network_client = NetworkManagementClient(
223+
credential=credential,
224+
subscription_id=SUBSCRIPTION_ID
225+
)
226+
227+
**Create a Network Public IP Address Async**
228+
::
229+
230+
GROUP_NAME = "testgroup"
231+
PUBLIC_IP_ADDRESS = "public_ip_address_name"
232+
233+
# Create Resource Group
234+
await resource_client.resource_groups.create_or_update(
235+
GROUP_NAME,
236+
{"location": "eastus"}
237+
)
238+
239+
# Create Public IP Address
240+
async_poller = await network_client.public_ip_addresses.begin_create_or_update(
241+
GROUP_NAME,
242+
PUBLIC_IP_ADDRESS,
243+
{
244+
"location": "eastus"
245+
}
246+
)
247+
public_ip_address = await async_poller.result()
248+
print("Create Public IP Address:\n{}".format(public_ip_address))
249+
250+
Code Samples
251+
-------------------------
252+
For more code samples, please see `here <https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing>`__
253+
254+
Need help?
255+
----------
256+
- File an issue via `Github Issues <https://github.com/Azure/azure-sdk-for-python/issues>`__ and make sure you add the "Preview" label to the issue
257+
- Check `previous questions <https://stackoverflow.com/questions/tagged/azure+python>`__ or ask new ones on StackOverflow using azure and python tags.
258+
259+
Contributing
260+
------------
261+
For details on contributing to this repository, see the contributing guide.
262+
263+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
264+
265+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
266+
267+
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

eng/pipelines/aggregate-reports.yml

-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
resources:
2-
repositories:
3-
- repository: azure-sdk-tools
4-
type: github
5-
name: Azure/azure-sdk-tools
6-
endpoint: azure
7-
- repository: azure-sdk-build-tools
8-
type: git
9-
name: internal/azure-sdk-build-tools
10-
111
trigger: none
122
pr: none
133

eng/pipelines/create-doc-index.yml

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
trigger: none
22

3-
resources:
4-
repositories:
5-
- repository: azure-sdk-tools
6-
type: github
7-
name: Azure/azure-sdk-tools
8-
endpoint: azure
9-
103
variables:
114
PythonVersion: '3.6'
125

@@ -27,7 +20,7 @@ jobs:
2720
inputs:
2821
versionSpec: $(PythonVersion)
2922

30-
- template: eng/pipelines/templates/scripts/replace-relative-links.yml@azure-sdk-tools
23+
- template: /eng/common/pipelines/templates/steps/replace-relative-links.yml
3124
parameters:
3225
TargetFolder: '.'
3326
RootFolder: '.'

eng/pipelines/generate-all-docs.yml

-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
trigger: none
22

3-
resources:
4-
repositories:
5-
- repository: azure-sdk-tools
6-
type: github
7-
name: Azure/azure-sdk-tools
8-
endpoint: azure
9-
103
variables:
114
PythonVersion: '3.6'
125

eng/pipelines/templates/jobs/archetype-sdk-client.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,31 @@ parameters:
99
BuildDocs: true
1010
TestMatrix:
1111
Linux_Python27:
12-
OSName: 'Linux'
1312
OSVmImage: 'ubuntu-18.04'
1413
PythonVersion: '2.7'
1514
CoverageArg: ''
1615
RunForPR: true
1716
Linux_Python35:
18-
OSName: 'Linux'
1917
OSVmImage: 'ubuntu-18.04'
2018
PythonVersion: '3.5'
2119
CoverageArg: ''
2220
RunForPR: false
2321
Linux_Python38:
24-
OSName: 'Linux'
2522
OSVmImage: 'ubuntu-18.04'
2623
PythonVersion: '3.8'
2724
CoverageArg: ''
2825
RunForPR: true
2926
Windows_Python35:
30-
OSName: 'Windows'
3127
OSVmImage: 'windows-2019'
3228
PythonVersion: '3.5'
3329
CoverageArg: ''
3430
RunForPR: true
3531
MacOS_Python27:
36-
OSName: 'MacOS'
3732
OSVmImage: 'macOS-10.15'
3833
PythonVersion: '2.7'
3934
CoverageArg: ''
4035
RunForPR: false
4136
Linux_pypy3:
42-
OSName: 'Linux'
4337
OSVmImage: 'ubuntu-18.04'
4438
PythonVersion: 'pypy3'
4539
CoverageArg: '--disablecov'
@@ -117,7 +111,7 @@ jobs:
117111
ServiceDirectory: ${{ parameters.ServiceDirectory }}
118112
TestMarkArgument: ${{ parameters.TestMarkArgument }}
119113
AdditionalTestArgs: '--wheel_dir="$(Build.ArtifactStagingDirectory)"'
120-
OSName: $(OSName)
114+
OSVmImage: $(OSVmImage)
121115
CoverageArg: $(CoverageArg)
122116
PythonVersion: $(PythonVersion)
123117
BuildTargetingString: ${{ parameters.BuildTargetingString }}

0 commit comments

Comments
 (0)