public static PSBlobContainerDataSet ToPsObject(this BlobContainerDataSet blobContainerDataSet)
 {
     return(new PSBlobContainerDataSet
     {
         Id = blobContainerDataSet.Id,
         Name = blobContainerDataSet.Name,
         Type = blobContainerDataSet.Type,
         DataSetId = blobContainerDataSet.DataSetId,
         ContainerName = blobContainerDataSet.ContainerName,
         SubscriptionId = blobContainerDataSet.SubscriptionId,
         ResourceGroup = blobContainerDataSet.ResourceGroup,
         StorageAccount = blobContainerDataSet.StorageAccountName
     });
 }
Beispiel #2
0
        public DataSet CreateIfNotExistDataSet(Principal principal)
        {
            DataSet dataSet;

            try
            {
                dataSet = this.DataShareClient.DataSets.Get(
                    this.Principal.DataShareResourceGroup,
                    this.Principal.DataShareAccountName,
                    this.Principal.DataShareShareName,
                    this.Principal.DataShareDataSetName);

                Console.WriteLine($"\r\n\r\nReturning existing data set {dataSet.Id}...");

                return(dataSet);
            }
            catch (DataShareErrorException exception)
            {
                if (exception.Response.StatusCode == HttpStatusCode.NotFound)
                {
                    Console.WriteLine("\r\n\r\nData set does not exist, creating new...");
                    var containerDataSetPayload = new BlobContainerDataSet
                    {
                        SubscriptionId     = principal.SubscriptionId,
                        ResourceGroup      = principal.StorageResourceGroup,
                        StorageAccountName = principal.StorageAccountName,
                        ContainerName      = principal.StorageContainerName
                    };

                    dataSet = this.DataShareClient.DataSets.Create(
                        this.Principal.DataShareResourceGroup,
                        this.Principal.DataShareAccountName,
                        this.Principal.DataShareShareName,
                        this.Principal.DataShareDataSetName,
                        containerDataSetPayload);

                    Console.WriteLine($"\r\n\r\nReturning new data set {dataSet.Id}...");

                    return(dataSet);
                }

                Console.WriteLine($"\r\n\r\nUnexpected error occured while creating data set - {exception.Body.Error.Message}");

                throw;
            }
        }