示例#1
0
        public async Task CreateBlobStorage()
        {
            messageContainer.AddInformationMessage("Creating blob storage connection...");
            blobContainer = new BlobStorage(AzureConnectionUtility.BlobConnectionString, messageContainer);
            await blobContainer.CreateBlobStorage(AzureConnectionUtility.BuildProjectNameReference());

            messageContainer.AddStatusMessage("Blob container created!");
        }
        public AzureBatchClient(String accountName = null, String accountKey = null, String accountURL = null, BlobStorage storage = null, String poolID = null, String jobID = null, int poolNodeCount = 2, String poolVMSize = null, SystemMessageContainer container = null)
        {
            if (accountName == null)
            {
                throw new NullReferenceException("Please provide a valid batch account name");
            }
            if (accountKey == null)
            {
                throw new NullReferenceException("Please provide a valid batch account key");
            }
            if (accountURL == null)
            {
                throw new NullReferenceException("Please provide a valid batch account URL");
            }
            if (storage == null)
            {
                throw new NullReferenceException("Please provide a valid blob storange reference");
            }

            batchAccountName = accountName;
            batchAccountKey  = accountKey;
            batchAccountURL  = accountURL;
            blobStorage      = storage;

            poolID     = (poolID == null ? AzureConnectionUtility.BuildProjectNameReference() + "-pool" : poolID);
            jobID      = (jobID == null ? AzureConnectionUtility.BuildProjectNameReference() + "-job" : jobID);
            poolVMSize = (poolVMSize == null ? "Basic_A1" : poolVMSize);

            messageContainer = (container == null ? new SystemMessageContainer() : container);

            messageContainer.AddInformationMessage("Creating batch client...");

            batchClient = BatchClient.Open(new BatchSharedKeyCredentials(batchAccountURL, batchAccountName, batchAccountKey));
            messageContainer.AddInformationMessage("Batch client created...");

            //Create the pool if it doesn't exist
            pool = CreatePoolIfNotExists(poolID, poolVMSize, poolNodeCount);
            job  = CreateJobIfNotExists(jobID, pool.Id);
        }
示例#3
0
        public void CreateBatchClients(int filesToRun)
        {
            messageContainer.AddInformationMessage("Creating batch client(s)...");

            //Each batch pool can only have 100 nodes, and we want to use one node per file. If we have more than 100 nodes we need to create more than one batch client
            int maxClients        = (int)Math.Ceiling((double)filesToRun / 100);
            int numberOfFullNodes = (int)Math.Floor((double)filesToRun / 100);

            for (int x = 0; x < maxClients; x++)
            {
                //Create a new batch client with the pool size either 100 or max files
                int numNodes            = (int)(x < numberOfFullNodes ? 100 : filesToRun % 100);
                AzureBatchClient client = new AzureBatchClient(AzureConnectionUtility.BatchAccountName, AzureConnectionUtility.BatchAccountKey, AzureConnectionUtility.BatchAccountURL, blobContainer, AzureConnectionUtility.BuildProjectNameReference() + x.ToString(), AzureConnectionUtility.BuildProjectNameReference(), numNodes, AzureConnectionUtility.PoolVMSize, messageContainer);

                batchContainer.Add(client);
            }

            messageContainer.AddStatusMessage(maxClients + " Batch Clients created!");
        }