|
1 | 1 | # Microsoft Azure SDK for Python
|
2 | 2 |
|
3 |
| -This is the Microsoft Azure Service Management Legacy Client Library. |
4 |
| - |
5 |
| -All packages in this bundle have been tested with Python 2.7, 3.3, 3.4 and 3.5. |
6 |
| - |
7 |
| -For the newer Azure Resource Management (ARM) libraries, see [azure-mgmt](https://pypi.python.org/pypi/azure-mgmt). |
8 |
| - |
9 |
| -For a more complete set of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). |
10 |
| - |
11 |
| - |
12 |
| -# Compatibility |
13 |
| - |
14 |
| -**IMPORTANT**: If you have an earlier version of the azure package |
15 |
| -(version < 1.0), you should uninstall it before installing this package. |
16 |
| - |
17 |
| -You can check the version using pip: |
18 |
| - |
19 |
| -```shell |
20 |
| -pip freeze |
21 |
| -``` |
22 |
| - |
23 |
| -If you see azure==0.11.0 (or any version below 1.0), uninstall it first: |
24 |
| - |
25 |
| -```shell |
26 |
| -pip uninstall azure |
27 |
| -``` |
28 |
| - |
29 |
| -# Features |
30 |
| - |
31 |
| -- Cloud Service management (Virtual Machines, VM Images, OS Images) |
32 |
| -- Storage accounts management |
33 |
| -- Scheduler management |
34 |
| -- Service Bus management |
35 |
| -- Affinity Group management |
36 |
| -- Management certificate management |
37 |
| -- Web Apps (Website) management |
38 |
| - |
39 |
| - |
40 |
| -# Installation |
41 |
| - |
42 |
| -## Download Package |
43 |
| - |
44 |
| -To install via the Python Package Index (PyPI), type: |
45 |
| - |
46 |
| -```shell |
47 |
| -pip install azure-servicemanagement-legacy |
48 |
| -``` |
49 |
| - |
50 |
| - |
51 |
| -## Download Source Code |
52 |
| - |
53 |
| -To get the source code of the SDK via **git** type: |
54 |
| - |
55 |
| -```shell |
56 |
| -git clone https://github.com/Azure/azure-sdk-for-python.git |
57 |
| -cd azure-sdk-for-python |
58 |
| -cd azure-servicemanagement-legacy |
59 |
| -python setup.py install |
60 |
| -``` |
61 |
| - |
62 |
| - |
63 |
| -# Usage |
64 |
| - |
65 |
| -## Authentication |
66 |
| - |
67 |
| -### Set-up certificates |
68 |
| - |
69 |
| -You will need two certificates, one for the server (a .cer file) and one for |
70 |
| -the client (a .pem file). |
71 |
| - |
72 |
| -### Using the Azure .PublishSettings certificate |
73 |
| - |
74 |
| -You can download your Azure publish settings file and use the certificate that |
75 |
| -is embedded in that file to create the client certificate. The server |
76 |
| -certificate already exists, so you won't need to upload one. |
77 |
| - |
78 |
| -To do this, download your [publish settings](https://go.microsoft.com/fwlink/?LinkID=301775) |
79 |
| -then use this code to create the .pem file. |
80 |
| - |
81 |
| -```python |
82 |
| -from azure.servicemanagement import get_certificate_from_publish_settings |
83 |
| - |
84 |
| -subscription_id = get_certificate_from_publish_settings( |
85 |
| - publish_settings_path='MyAccount.PublishSettings', |
86 |
| - path_to_write_certificate='mycert.pem', |
87 |
| - subscription_id='00000000-0000-0000-0000-000000000000', |
88 |
| -) |
89 |
| -``` |
90 |
| - |
91 |
| -The subscription id parameter is optional. If there are more than one |
92 |
| -subscription in the publish settings, the first one will be used. |
93 |
| - |
94 |
| -### Creating and uploading new certificate with OpenSSL |
95 |
| - |
96 |
| -To create the .pem file using [OpenSSL](https://www.openssl.org), execute this: |
97 |
| - |
98 |
| -```shell |
99 |
| -openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem |
100 |
| -``` |
101 |
| -To create the .cer certificate, execute this: |
102 |
| - |
103 |
| -```shell |
104 |
| -openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer |
105 |
| -``` |
106 |
| - |
107 |
| -After you have created the certificate, you will need to upload the .cer |
108 |
| -file to Microsoft Azure via the "Upload" action of the "Settings" tab of |
109 |
| -the [management portal](https://portal.azure.com). |
110 |
| - |
111 |
| - |
112 |
| -## ServiceManagementService |
113 |
| - |
114 |
| -### Initialization |
115 |
| - |
116 |
| -To initialize the management service, pass in your subscription id and |
117 |
| -the path to the .pem file. |
118 |
| - |
119 |
| -```python |
120 |
| -from azure.servicemanagement import ServiceManagementService |
121 |
| -subscription_id = '00000000-0000-0000-0000-000000000000' |
122 |
| -cert_file = 'mycert.pem' |
123 |
| -sms = ServiceManagementService(subscription_id, cert_file) |
124 |
| -``` |
125 |
| - |
126 |
| -### List Available Locations |
127 |
| - |
128 |
| -```python |
129 |
| -locations = sms.list_locations() |
130 |
| -for location in locations: |
131 |
| - print(location.name) |
132 |
| -``` |
133 |
| - |
134 |
| -### Create a Storage Service |
135 |
| - |
136 |
| -To create a storage service, you need a name for the service (between 3 |
137 |
| -and 24 lowercase characters and unique within Microsoft Azure), a label |
138 |
| -(up to 100 characters, automatically encoded to base-64), and either a |
139 |
| -location or an affinity group. |
140 |
| - |
141 |
| -```python |
142 |
| -name = "mystorageservice" |
143 |
| -desc = name |
144 |
| -label = name |
145 |
| -location = 'West US' |
146 |
| - |
147 |
| -result = sms.create_storage_account(name, desc, label, location=location) |
148 |
| -sms.wait_for_operation_status(result.request_id, timeout=30) |
149 |
| -``` |
150 |
| - |
151 |
| -### Create a Cloud Service |
152 |
| - |
153 |
| -A cloud service is also known as a hosted service (from earlier versions |
154 |
| -of Microsoft Azure). The **create\_hosted\_service** method allows you |
155 |
| -to create a new hosted service by providing a hosted service name (which |
156 |
| -must be unique in Microsoft Azure), a label (automatically encoded to |
157 |
| -base-64), and the location *or* the affinity group for your service. |
158 |
| - |
159 |
| -```python |
160 |
| -name = "myhostedservice" |
161 |
| -desc = name |
162 |
| -label = name |
163 |
| -location = 'West US' |
164 |
| - |
165 |
| -result = sms.create_hosted_service(name, label, desc, location=location) |
166 |
| -sms.wait_for_operation_status(result.request_id, timeout=30) |
167 |
| -``` |
168 |
| - |
169 |
| -### Create a Virtual Machine |
170 |
| - |
171 |
| -To create a virtual machine, you first need to create a cloud service. |
172 |
| -Then create the virtual machine deployment using the |
173 |
| -create_virtual_machine_deployment method. |
174 |
| - |
175 |
| -```python |
176 |
| -from azure.servicemanagement import LinuxConfigurationSet, OSVirtualHardDisk |
177 |
| - |
178 |
| -name = "myhostedservice" |
179 |
| - |
180 |
| -# Name of an os image as returned by list_os_images |
181 |
| -image_name = 'OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd' |
182 |
| - |
183 |
| -# Destination storage account container/blob where the VM disk |
184 |
| -# will be created |
185 |
| -media_link = 'url_to_target_storage_blob_for_vm_hd' |
186 |
| - |
187 |
| -# Linux VM configuration, you can use WindowsConfigurationSet |
188 |
| -# for a Windows VM instead |
189 |
| -linux_config = LinuxConfigurationSet( |
190 |
| - 'myhostname', |
191 |
| - 'myuser', |
192 |
| - 'mypassword', |
193 |
| - disable_ssh_password_authentication=True, |
194 |
| -) |
195 |
| - |
196 |
| -os_hd = OSVirtualHardDisk(image_name, media_link) |
197 |
| - |
198 |
| -result = sms.create_virtual_machine_deployment( |
199 |
| - service_name=name, |
200 |
| - deployment_name=name, |
201 |
| - deployment_slot='production', |
202 |
| - label=name, |
203 |
| - role_name=name, |
204 |
| - system_config=linux_config, |
205 |
| - os_virtual_hard_disk=os_hd, |
206 |
| - role_size='Small', |
207 |
| -) |
208 |
| -sms.wait_for_operation_status(result.request_id, timeout=600) |
209 |
| -``` |
210 |
| - |
211 |
| - |
212 |
| -# Need Help? |
213 |
| - |
214 |
| -Be sure to check out the Microsoft Azure [Developer Forums on Stack |
215 |
| -Overflow](https://go.microsoft.com/fwlink/?LinkId=234489) if you have |
216 |
| -trouble with the provided code. |
217 |
| - |
218 |
| - |
219 |
| -# Contribute Code or Provide Feedback |
220 |
| - |
221 |
| -If you would like to become an active contributor to this project please |
222 |
| -follow the instructions provided in [Microsoft Azure Projects |
223 |
| -Contribution |
224 |
| -Guidelines](https://azure.github.io/guidelines.html). |
225 |
| - |
226 |
| -If you encounter any bugs with the library please file an issue in the |
227 |
| -[Issues](https://github.com/Azure/azure-sdk-for-python/issues) |
228 |
| -section of the project. |
229 |
| - |
230 |
| - |
231 |
| -# Learn More |
232 |
| - |
233 |
| -[Microsoft Azure Python Developer |
234 |
| -Center](https://azure.microsoft.com/develop/python/) |
235 |
| - |
236 |
| - |
237 |
| - |
| 3 | +This package has been deprecated and will no longer be maintained after 10-31-2024. This package will only receive security fixes until 10-31-2024. To receive updates on new features and non-security bug fixes, upgrade to the specific service management package listed [here](https://azure.github.io/azure-sdk/releases/latest/all/python.html). |
0 commit comments