示例#1
0
        public static Uri UploadPackageToBlob(IServiceManagement channel, string storageName, string subscriptionId, string packagePath)
        {
            StorageService storageKeys = channel.GetStorageKeys(subscriptionId, storageName);
            string         primary     = storageKeys.StorageServiceKeys.Primary;

            storageKeys = channel.GetStorageService(subscriptionId, storageName);
            EndpointList endpoints = storageKeys.StorageServiceProperties.Endpoints;
            string       str       = ((List <string>)endpoints).Find((string p) => p.Contains(".blob."));

            return(AzureBlob.UploadFile(storageName, primary, str, packagePath));
        }
示例#2
0
        private static Uri UploadFile(string storageName, string storageKey, string blobStorageEndpoint, string filePath)
        {
            StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(storageName, storageKey);
            CloudBlobClient cloudBlobClient = new CloudBlobClient(blobStorageEndpoint, storageCredentialsAccountAndKey);

            object[] str    = new object[2];
            DateTime utcNow = DateTime.UtcNow;

            str[0] = utcNow.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture);
            str[1] = Path.GetFileName(filePath);
            string             str1 = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", str);
            CloudBlobContainer containerReference = cloudBlobClient.GetContainerReference("mydeployments");

            containerReference.CreateIfNotExist();
            CloudBlob blobReference = containerReference.GetBlobReference(str1);

            AzureBlob.UploadBlobStream(blobReference, filePath);
            object[] baseUri = new object[4];
            baseUri[0] = cloudBlobClient.BaseUri;
            baseUri[1] = "mydeployments";
            baseUri[2] = cloudBlobClient.DefaultDelimiter;
            baseUri[3] = str1;
            return(new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", baseUri)));
        }