Skip to content

Commit 91d92f4

Browse files
authored
Add new workspace connection types. (Azure#31295)
* changes * changelog * redo recordings * fix error in automatic recording creation * api key support * surface new credential class * comments
1 parent f2a9f28 commit 91d92f4

File tree

22 files changed

+3656
-602
lines changed

22 files changed

+3656
-602
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
### Features Added
77
- Added support of features that are known into the future/at forecast time for dnn in AutoML Forecasting jobs.
8+
- Added support for new workspace connection types: azure_open_ai, cognitive_search, and cognitive_service.
9+
- Added support for new credential type: ApiKeyConfiguration.
810
- Added support of `download` for component operations.
911

1012
### Bugs Fixed
@@ -18,6 +20,7 @@
1820

1921
- `azure-ai-ml` now performs all file i/o on `utf-8` encoded files per Azure SDK guidance.
2022
(instead of the default behavior for python < 3.15, which uses locale specific encodings)
23+
- Removed references to deprecated "feature_store" workspace connection type.
2124

2225
## 1.9.0 (2023-07-25)
2326

@@ -28,7 +31,6 @@
2831

2932
- Improved the output when printing a workspace object to be more clean and readable.
3033
- Log level of unknown field notifications for pipeline nodes raised from INFO to WARNING.
31-
3234
## 1.8.0 (2023-06-12)
3335

3436
### Features Added

sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from azure.ai.ml._restclient.v2020_09_01_dataplanepreview import (
2828
AzureMachineLearningWorkspaces as ServiceClient092020DataplanePreview,
2929
)
30+
3031
from azure.ai.ml._restclient.v2022_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022022Preview
3132
from azure.ai.ml._restclient.v2022_05_01 import AzureMachineLearningWorkspaces as ServiceClient052022
3233
from azure.ai.ml._restclient.v2022_10_01 import AzureMachineLearningWorkspaces as ServiceClient102022
@@ -305,6 +306,13 @@ def __init__(
305306
**kwargs,
306307
)
307308

309+
self._service_client_06_2023_preview = ServiceClient062023Preview(
310+
credential=self._credential,
311+
subscription_id=self._operation_scope._subscription_id,
312+
base_url=base_url,
313+
**kwargs,
314+
)
315+
308316
self._workspaces = WorkspaceOperations(
309317
self._operation_scope,
310318
self._service_client_06_2023_preview,
@@ -335,7 +343,7 @@ def __init__(
335343
self._workspace_connections = WorkspaceConnectionsOperations(
336344
self._operation_scope,
337345
self._operation_config,
338-
self._service_client_04_2023_preview,
346+
self._service_client_06_2023_preview,
339347
self._operation_container,
340348
self._credential,
341349
)

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/connections/workspace_connection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from marshmallow import fields, post_load
88

9-
from azure.ai.ml._restclient.v2023_04_01_preview.models import ConnectionCategory
9+
from azure.ai.ml._restclient.v2023_06_01_preview.models import ConnectionCategory
1010
from azure.ai.ml._schema.core.fields import ArmStr, NestedField, StringTransformedEnum, UnionField
1111
from azure.ai.ml._schema.core.schema import PathAwareSchema
1212
from azure.ai.ml._schema.job import CreationContextSchema
@@ -31,13 +31,15 @@ class WorkspaceConnectionSchema(PathAwareSchema):
3131
ConnectionCategory.GIT,
3232
ConnectionCategory.CONTAINER_REGISTRY,
3333
ConnectionCategory.PYTHON_FEED,
34-
ConnectionCategory.FEATURE_STORE,
3534
ConnectionCategory.S3,
3635
ConnectionCategory.SNOWFLAKE,
3736
ConnectionCategory.AZURE_SQL_DB,
3837
ConnectionCategory.AZURE_SYNAPSE_ANALYTICS,
3938
ConnectionCategory.AZURE_MY_SQL_DB,
4039
ConnectionCategory.AZURE_POSTGRES_DB,
40+
ConnectionCategory.AZURE_OPEN_AI,
41+
ConnectionCategory.COGNITIVE_SERVICE,
42+
ConnectionCategory.COGNITIVE_SEARCH,
4143
],
4244
casing_transform=camel_to_snake,
4345
required=True,

sdk/ml/azure-ai-ml/azure/ai/ml/entities/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
UserIdentityConfiguration,
5151
UsernamePasswordConfiguration,
5252
AccessKeyConfiguration,
53+
ApiKeyConfiguration
5354
)
5455
from ._datastore.adls_gen1 import AzureDataLakeGen1Datastore
5556
from ._datastore.azure_storage import AzureBlobDatastore, AzureDataLakeGen2Datastore, AzureFileDatastore
@@ -397,6 +398,7 @@
397398
"Route",
398399
"AccessKeyConfiguration",
399400
"AlertNotification",
401+
"ApiKeyConfiguration",
400402
"MonitorDefinition",
401403
"MonitorInputData",
402404
"MonitorSchedule",

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_credentials.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from azure.ai.ml._restclient.v2022_10_01.models import (
4343
ServicePrincipalDatastoreSecrets as RestServicePrincipalDatastoreSecrets,
4444
)
45+
4546
from azure.ai.ml._restclient.v2023_04_01_preview.models import AmlToken as RestAmlToken
4647
from azure.ai.ml._restclient.v2023_04_01_preview.models import ConnectionAuthType
4748
from azure.ai.ml._restclient.v2023_04_01_preview.models import IdentityConfiguration as RestJobIdentityConfiguration
@@ -52,10 +53,15 @@
5253
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
5354
WorkspaceConnectionAccessKey as RestWorkspaceConnectionAccessKey,
5455
)
56+
from azure.ai.ml._restclient.v2023_06_01_preview.models import ConnectionAuthType
57+
from azure.ai.ml._restclient.v2023_06_01_preview.models import (
58+
WorkspaceConnectionApiKey as WorkspaceConnectionApiKey,
59+
)
5560
from azure.ai.ml._utils.utils import camel_to_snake, snake_to_pascal
5661
from azure.ai.ml.constants._common import CommonYamlFields, IdentityType
5762
from azure.ai.ml.entities._mixins import DictMixin, RestTranslatableMixin, YamlTranslatableMixin
5863
from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, JobException, ValidationErrorType, ValidationException
64+
from azure.ai.ml._utils._experimental import experimental
5965

6066

6167
class _BaseIdentityConfiguration(ABC, DictMixin, RestTranslatableMixin):
@@ -776,3 +782,38 @@ def __eq__(self, other: object) -> bool:
776782
if not isinstance(other, AccessKeyConfiguration):
777783
return NotImplemented
778784
return self.access_key_id == other.access_key_id and self.secret_access_key == other.secret_access_key
785+
786+
@experimental
787+
class ApiKeyConfiguration(RestTranslatableMixin, DictMixin):
788+
"""Api Key Credentials.
789+
790+
:param key: API key id
791+
:type key: str
792+
"""
793+
794+
def __init__(
795+
self,
796+
*,
797+
key: str,
798+
):
799+
super().__init__()
800+
self.type = camel_to_snake(ConnectionAuthType.API_KEY)
801+
self.key = key
802+
803+
def _to_workspace_connection_rest_object(self) -> WorkspaceConnectionApiKey:
804+
return WorkspaceConnectionApiKey(
805+
key=self.key,
806+
)
807+
808+
@classmethod
809+
def _from_workspace_connection_rest_object(
810+
cls, obj: Optional[WorkspaceConnectionApiKey]
811+
) -> "AccessKeyConfiguration":
812+
return cls(
813+
key=obj.key if obj is not None and obj.key else None,
814+
)
815+
816+
def __eq__(self, other: object) -> bool:
817+
if not isinstance(other, AccessKeyConfiguration):
818+
return NotImplemented
819+
return self.key == other.key

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_workspace/connections/workspace_connection.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
from pathlib import Path
1010
from typing import IO, Any, AnyStr, Dict, Optional, Union
1111

12-
from azure.ai.ml._restclient.v2022_01_01_preview.models import (
12+
from azure.ai.ml._restclient.v2023_06_01_preview.models import (
1313
ManagedIdentityAuthTypeWorkspaceConnectionProperties,
1414
NoneAuthTypeWorkspaceConnectionProperties,
1515
PATAuthTypeWorkspaceConnectionProperties,
1616
SASAuthTypeWorkspaceConnectionProperties,
1717
ServicePrincipalAuthTypeWorkspaceConnectionProperties,
1818
UsernamePasswordAuthTypeWorkspaceConnectionProperties,
19+
ApiKeyAuthWorkspaceConnectionProperties
1920
)
20-
from azure.ai.ml._restclient.v2022_01_01_preview.models import (
21+
from azure.ai.ml._restclient.v2023_06_01_preview.models import (
2122
WorkspaceConnectionPropertiesV2BasicResource as RestWorkspaceConnection,
2223
)
23-
from azure.ai.ml._restclient.v2023_04_01_preview.models import (
24+
from azure.ai.ml._restclient.v2023_06_01_preview.models import (
2425
ConnectionAuthType,
2526
AccessKeyAuthTypeWorkspaceConnectionProperties,
2627
)
@@ -35,6 +36,7 @@
3536
ServicePrincipalConfiguration,
3637
UsernamePasswordConfiguration,
3738
AccessKeyConfiguration,
39+
ApiKeyConfiguration
3840
)
3941
from azure.ai.ml.entities._resource import Resource
4042
from azure.ai.ml.entities._system_data import SystemData
@@ -54,12 +56,14 @@ class WorkspaceConnection(Resource):
5456
:type credentials: Union[
5557
~azure.ai.ml.entities.PatTokenConfiguration, ~azure.ai.ml.entities.SasTokenConfiguration,
5658
~azure.ai.ml.entities.UsernamePasswordConfiguration, ~azure.ai.ml.entities.ManagedIdentityConfiguration
57-
~azure.ai.ml.entities.ServicePrincipalConfiguration, ~azure.ai.ml.entities.AccessKeyConfiguration
59+
~azure.ai.ml.entities.ServicePrincipalConfiguration, ~azure.ai.ml.entities.AccessKeyConfiguration,
60+
~azure.ai.ml.entities.ApiKeyConfiguration
5861
]
5962
:param type: The category of external resource for this connection.
6063
:type type: The type of workspace connection, possible values are: [
6164
"git", "python_feed", "container_registry", "feature_store", "s3", "snowflake",
62-
"azure_sql_db", "azure_synapse_analytics", "azure_my_sql_db", "azure_postgres_db"
65+
"azure_sql_db", "azure_synapse_analytics", "azure_my_sql_db", "azure_postgres_db",
66+
"azure_open_ai", "cognitive_search", "cognitive_service"
6367
]
6468
"""
6569

@@ -203,6 +207,8 @@ def _from_rest_object(cls, rest_obj: RestWorkspaceConnection) -> "WorkspaceConne
203207
credentials = AccessKeyConfiguration._from_workspace_connection_rest_object(properties.credentials)
204208
if properties.auth_type == ConnectionAuthType.SERVICE_PRINCIPAL:
205209
credentials = ServicePrincipalConfiguration._from_workspace_connection_rest_object(properties.credentials)
210+
if properties.auth_type == ConnectionAuthType.API_KEY:
211+
credentials = ApiKeyConfiguration._from_workspace_connection_rest_object(properties.credentials)
206212

207213
workspace_connection = WorkspaceConnection(
208214
id=rest_obj.id,
@@ -235,6 +241,8 @@ def _to_rest_object(self) -> RestWorkspaceConnection:
235241
workspace_connection_properties_class = SASAuthTypeWorkspaceConnectionProperties
236242
elif auth_type == camel_to_snake(ConnectionAuthType.SERVICE_PRINCIPAL):
237243
workspace_connection_properties_class = ServicePrincipalAuthTypeWorkspaceConnectionProperties
244+
elif auth_type == camel_to_snake(ConnectionAuthType.API_KEY):
245+
workspace_connection_properties_class = ApiKeyAuthWorkspaceConnectionProperties
238246
elif auth_type is None:
239247
workspace_connection_properties_class = NoneAuthTypeWorkspaceConnectionProperties
240248

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_workspace_connections_operations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from typing import Dict, Iterable, Optional
88

9-
from azure.ai.ml._restclient.v2022_05_01 import AzureMachineLearningWorkspaces as ServiceClient052022
9+
from azure.ai.ml._restclient.v2023_06_01_preview import AzureMachineLearningWorkspaces as ServiceClient062023Preview
1010
from azure.ai.ml._scope_dependent_operations import (
1111
OperationConfig,
1212
OperationsContainer,
@@ -34,7 +34,7 @@ def __init__(
3434
self,
3535
operation_scope: OperationScope,
3636
operation_config: OperationConfig,
37-
service_client: ServiceClient052022,
37+
service_client: ServiceClient062023Preview,
3838
all_operations: OperationsContainer,
3939
credentials: Optional[TokenCredential] = None,
4040
**kwargs: Dict,
@@ -79,7 +79,7 @@ def create_or_update(self, workspace_connection, **kwargs) -> WorkspaceConnectio
7979
response = self._operation.create(
8080
workspace_name=self._workspace_name,
8181
connection_name=workspace_connection.name,
82-
parameters=rest_workspace_connection,
82+
body=rest_workspace_connection,
8383
**self._scope_kwargs,
8484
**kwargs,
8585
)

0 commit comments

Comments
 (0)