Closed
Description
openedon Aug 8, 2023
Getting dataset properties throwing error
#!/usr/bin/env python
from azure.identity import DefaultAzureCredential
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.mgmt.datafactory.models import DatasetResource
from azure.identity import DefaultAzureCredential
from azure.identity import ClientSecretCredential
import json
# Replace with your Azure subscription ID and resource group name
subscription_id = '<subid>'
credential = DefaultAzureCredential()
resource_group_name = "<myrg>"
data_factory_name = "<myadf>"
adf_client = DataFactoryManagementClient(credential, subscription_id)
# Define dataset properties
dataset_name = "test_dataset"
dataset = '{"properties": {"linkedServiceName": { "referenceName": "AzureSqlDatabase1","type": "LinkedServiceReference"},"type": "AzureSqlTable","folder": {"name": "azuresql_test"},"typeProperties": {"schema": "sales","table": "customers"}}}'
dataset = json.loads(dataset)
print(dataset)
# Create the dataset in the Data Factory
adf_client.datasets.create_or_update(resource_group_name, data_factory_name, dataset_name, dataset)
print("created dataset")
# Fetch the dataset schema
print("Fetch the dataset schema")
dataset = adf_client.datasets.get(resource_group_name, data_factory_name, dataset_name)
print('dataset', dataset)
schema = dataset.properties["typeProperties"]["schema"]
# Now you can use the 'schema' dictionary to get information about column names, data types, etc.
print(schema)
Dataset created but I am getting error, while fetching the dataset schema,
TypeError: 'AzureSqlTableDataset' object is not subscriptable
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: ac5193bb-f6de-6274-54fa-af2b3898eed6
- Version Independent ID: 6fa6f87f-6c5a-ed5f-7483-2fe202d22d85
- Content: Microsoft Azure SDK for Python
- Content Source: docs-ref-services/latest/mgmt-datafactory-readme.md
- Service: datafactory
- GitHub Login: @hvermis
- Microsoft Alias: hvermis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
This issue is related to a management-plane library.Issues that are reported by GitHub users external to the Azure organization.Workflow: The Azure SDK team believes it to be addressed and ready to close.The issue doesn't require a change to the product in order to be resolved. Most issues start as that