Debian Codegraph @

ansible_collections/azure/azcollection/plugins/modules/azure_rm_ml_online_deployment_info.py

raw symbols SCIP
1 #!/usr/bin/python
2 #
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import absolute_import, division, print_function
6 __metaclass__ = type
7
8 DOCUMENTATION = '''
9 ---
10 module: azure_rm_ml_online_deployment_info
11 version_added: "3.17.0"
12 short_description: List ML Online Deployment resources
13 description:
14 - List ML Online Deployment resources.
15 options:
16 name:
17 description:
18 - Name of the deployment.
19 type: str
20 required: false
21 endpoint_name:
22 description:
23 - Name of the endpoint.
24 required: true
25 type: str
26 resource_group:
27 description:
28 - Name of resource group.
29 required: true
30 type: str
31 ml_workspace:
32 description:
33 - Name of the Azure ML workspace.
34 required: true
35 type: str
36 local:
37 description:
38 - List all local deployments.
39 type: bool
40 default: false
41
42 extends_documentation_fragment:
43 - azure.azcollection.azure
44
45 author:
46 - Bill Peck (@p3ck)
47 '''
48
49 EXAMPLES = '''
50 - name: Get Specific ML Online Deployment by name
51 azure.azcollection.azure_rm_ml_online_deployment_info:
52 name: deployment-command-xxxxxxxxxx
53 endpoint_name: endpoint-command-xxxxxxxxxx
54 resource_group: myResourceGroup
55 ml_workspace: myMLWorkspace
56
57 - name: List Local ML Online Deployments
58 azure.azcollection.azure_rm_ml_online_deployment_info:
59 endpoint_name: endpoint-command-xxxxxxxxxx
60 resource_group: myResourceGroup
61 ml_workspace: myMLWorkspace
62 local: true
63 '''
64
65 RETURN = '''
66 ml_online_deployments:
67 description:
68 - Online Deployments that match the query.
69 returned: always
70 type: dict
71 sample: [
72 {
73 "app_insights_enabled": false,
74 "code_configuration": {
75 "code": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-online_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/codes/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/versions/1",
76 "scoring_script": "score.py"
77 },
78 "creation_context": {
79 "created_at": "2026-04-17T20:39:38.864149+00:00",
80 "created_by": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
81 "last_modified_at": "2026-04-17T20:39:38.864151+00:00"
82 },
83 "egress_public_network_access": "enabled",
84 "endpoint_name": "endpoint-command-ansible",
85 "environment": "azureml:/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-online_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/environments/CliV2AnonymousEnvironment/versions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
86 "environment_variables": {
87 "AML_APP_ROOT": "/var/azureml-app/onlinescoring",
88 "AZUREML_ENTRY_SCRIPT": "score.py",
89 "AZUREML_MODEL_DIR": "/var/azureml-app/azureml-models/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/1"
90 },
91 "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-online_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/onlineEndpoints/endpoint-command-ansible/deployments/deployment-command-xxxxxxxxxx",
92 "instance_count": 1,
93 "instance_type": "Standard_DS3_v2",
94 "liveness_probe": {
95 "failure_threshold": 30,
96 "initial_delay": 10,
97 "period": 10,
98 "success_threshold": 1,
99 "timeout": 2
100 },
101 "model": "azureml:/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-online_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/models/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/versions/1",
102 "name": "deployment-command-e76e189747",
103 "properties": {
104 "AzureAsyncOperationUri": "https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.MachineLearningServices/locations/eastus/mfeOperationsStatus/odidp:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?api-version=2023-04-01-preview"
105 },
106 "provisioning_state": "Succeeded",
107 "readiness_probe": {
108 "failure_threshold": 30,
109 "initial_delay": 10,
110 "period": 10,
111 "success_threshold": 1,
112 "timeout": 2
113 },
114 "request_settings": {
115 "max_concurrent_requests_per_instance": 1,
116 "request_timeout_ms": 5000
117 },
118 "scale_settings": {
119 "type": "default"
120 },
121 "tags": {},
122 "type": "managed"
123 }
124 ]
125 ''' # NOQA
126
127
128 try:
129 from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ml import MLClientCommon
130 from azure.core.exceptions import ResourceNotFoundError
131 except ImportError:
132 # This is handled in azure_rm_common
133 pass
134
135
136 class AzureRMMLOnlineDeploymentInfo(MLClientCommon):
137 def __init__(self):
138
139 self.module_arg_spec = dict(
140 name=dict(
141 type='str',
142 required=False,
143 ),
144 endpoint_name=dict(
145 type='str',
146 required=True,
147 ),
148 resource_group=dict(
149 type='str',
150 required=True,
151 ),
152 ml_workspace=dict(
153 type='str',
154 required=True,
155 ),
156 local=dict(
157 type='bool',
158 default=False,
159 ),
160 )
161
162 self._client = None
163 self.ml_registry = None
164
165 self.results = dict(
166 ml_online_deployments=[]
167 )
168
169 super(AzureRMMLOnlineDeploymentInfo, self).__init__(self.module_arg_spec,
170 supports_tags=False,
171 supports_check_mode=True,
172 facts_module=True,
173 )
174
175 def exec_module(self, **kwargs):
176
177 for key in list(self.module_arg_spec.keys()):
178 setattr(self, key, kwargs[key])
179
180 if self.name:
181 ml_online_deployments = [self.get(self.name,
182 endpoint_name=self.endpoint_name,
183 local=self.local)]
184 else:
185 results = self.client.online_deployments.list(endpoint_name=self.endpoint_name,
186 local=self.local)
187 ml_online_deployments = [
188 self.get(x.name,
189 endpoint_name=self.endpoint_name,
190 local=self.local)
191 for x in results]
192
193 self.results['ml_online_deployments'] = ml_online_deployments
194 return self.results
195
196 def get(self, name, endpoint_name=None, local=False):
197 try:
198 result = self.client.online_deployments.get(name=name,
199 endpoint_name=endpoint_name,
200 local=self.local)
201 ml_online_deployment = self.entity_to_dict(result)
202 except ResourceNotFoundError:
203 ml_online_deployment = None
204
205 return ml_online_deployment
206
207
208 def main():
209 AzureRMMLOnlineDeploymentInfo()
210
211
212 if __name__ == '__main__':
213 main()