public override void ExecuteCmdlet() { var parsedStorageResourceId = new ResourceIdentifier(this.StorageAccountResourceId); string storageSubscriptionId = parsedStorageResourceId.Subscription; string storageResourceGroup = parsedStorageResourceId.ResourceGroupName; string storageAccountName = parsedStorageResourceId.GetStorageAccountName(); if (this.ParameterSetName.Equals( ParameterSetNames.BlobDataSetParameterSet, StringComparison.OrdinalIgnoreCase)) { if (this.ShouldProcess(this.Name, string.Format(Resources.ResourceCreateMessage, NewAzDataShareDataSetMapping.ResourceType))) { if (this.FilePath != null) { var newDataSetMapping = (BlobDataSetMapping)this.DataShareManagementClient.DataSetMappings.Create( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName, this.Name, new BlobDataSetMapping() { DataSetId = this.DataSetId, ContainerName = this.Container, FilePath = this.FilePath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSetMapping.ToPsObject()); } else if (this.FolderPath != null) { var newDataSetMapping = (BlobFolderDataSetMapping)this.DataShareManagementClient.DataSetMappings.Create( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName, this.Name, new BlobFolderDataSetMapping() { DataSetId = this.DataSetId, ContainerName = this.Container, Prefix = this.FolderPath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSetMapping.ToPsObject()); } else { var newDataSetMapping = (BlobContainerDataSetMapping)this.DataShareManagementClient.DataSetMappings.Create( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName, this.Name, new BlobContainerDataSetMapping() { DataSetId = this.DataSetId, ContainerName = this.Container, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSetMapping.ToPsObject()); } } } if (this.ParameterSetName.Equals( ParameterSetNames.AdlsGen2DataSetParameterSet, StringComparison.OrdinalIgnoreCase)) { if (this.ShouldProcess(this.Name, string.Format(Resources.ResourceCreateMessage, NewAzDataShareDataSetMapping.ResourceType))) { if (this.FilePath != null) { var newDataSetMapping = (ADLSGen2FileDataSetMapping)this.DataShareManagementClient.DataSetMappings.Create( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName, this.Name, new ADLSGen2FileDataSetMapping() { DataSetId = this.DataSetId, FileSystem = this.FileSystem, FilePath = this.FilePath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSetMapping.ToPsObject()); } else if (this.FolderPath != null) { var newDataSetMapping = (ADLSGen2FolderDataSetMapping)this.DataShareManagementClient.DataSetMappings.Create( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName, this.Name, new ADLSGen2FolderDataSetMapping() { DataSetId = this.DataSetId, FileSystem = this.FileSystem, FolderPath = this.FolderPath, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSetMapping.ToPsObject()); } else { var newDataSetMapping = (ADLSGen2FileSystemDataSetMapping)this.DataShareManagementClient.DataSetMappings.Create( this.ResourceGroupName, this.AccountName, this.ShareSubscriptionName, this.Name, new ADLSGen2FileSystemDataSetMapping() { DataSetId = this.DataSetId, FileSystem = this.FileSystem, ResourceGroup = storageResourceGroup, StorageAccountName = storageAccountName, SubscriptionId = storageSubscriptionId }); this.WriteObject(newDataSetMapping.ToPsObject()); } } } }