예제 #1
0
        /// <summary>
        /// Many SPN can be in configuration(appsettings.json). Default SpnAd should be in config.
        /// </summary>
        /// <param name="configSectionForSPN">string in Config section for SPN</param>
        /// <exception cref="ApplicationException"></exception>
        public virtual void InitSPN(string configSectionForSPN = nameof(SpnAd))
        {
            UseSpn = true;

            var spnAd = Configuration.GetSection(configSectionForSPN).Get <SpnAd>();

            if (spnAd == null)
            {
                throw new ApplicationException($"{spnAd} must be set in before calling method.");
            }

            if (spnAd != null)
            {
                if (!string.IsNullOrEmpty(spnAd.TenantId) &&
                    !string.IsNullOrEmpty(spnAd.ClientId) &&
                    !string.IsNullOrEmpty(spnAd.ClientSecret))
                {
                    ClientSecretCredential = new Azure.Identity.ClientSecretCredential(spnAd.TenantId, spnAd.ClientId, spnAd.ClientSecret);
                    TokenContext           = new Azure.Core.TokenRequestContext(new[] { Scope });
                }
            }
        }
예제 #2
0
        private async Task <(int tableCount, int propertiesGroupCount)> PrepareConfigContainerAsync(Azure.Identity.ClientSecretCredential credential, string containerName)
        {
            string              storageServiceUri = $"https://{_testSettings.AdlsAccountName}.blob.core.windows.net";
            BlobServiceClient   blobServiceClient = new BlobServiceClient(new Uri(storageServiceUri), credential);
            BlobContainerClient containerClient   = blobServiceClient.GetBlobContainerClient(containerName);
            await containerClient.CreateAsync();

            var tableDefinitions = Directory.EnumerateFiles(@"TestResource\TestSchema");

            foreach (string filePath in tableDefinitions)
            {
                await UploadFileAsync(containerClient, filePath);
            }

            var propertiesGroups = Directory.EnumerateFiles(@"TestResource\TestSchema\PropertiesGroup");

            foreach (string filePath in propertiesGroups)
            {
                await UploadFileAsync(containerClient, filePath, "PropertiesGroup/");
            }

            return(tableDefinitions.Count(), propertiesGroups.Count());
        }