当前位置: 首页>>代码示例>>C#>>正文


C# CloudPageBlob.GetSharedAccessSignature方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob.GetSharedAccessSignature方法的典型用法代码示例。如果您正苦于以下问题:C# CloudPageBlob.GetSharedAccessSignature方法的具体用法?C# CloudPageBlob.GetSharedAccessSignature怎么用?C# CloudPageBlob.GetSharedAccessSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob的用法示例。


在下文中一共展示了CloudPageBlob.GetSharedAccessSignature方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSasUriWithPermission

        private string CreateSasUriWithPermission(string vhdName, int p)
        {
            // Set the destination
            string vhdBlobName = string.Format("{0}/{1}.vhd", vhdContainerName, Utilities.GetUniqueShortName(Path.GetFileNameWithoutExtension(vhdName)));
            string httpsBlobUrlRoot = string.Format("https:{0}", blobUrlRoot.Substring(blobUrlRoot.IndexOf('/')));
            string vhdDestUri = httpsBlobUrlRoot + vhdBlobName;

            var destinationBlob2 = new CloudPageBlob(new Uri(vhdDestUri), new StorageCredentials(storageAccountKey.StorageAccountName, storageAccountKey.Primary));
            var policy2 = new SharedAccessBlobPolicy()
            {
                Permissions = (SharedAccessBlobPermissions)p,
                SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromHours(1)
            };
            var destinationBlobToken2 = destinationBlob2.GetSharedAccessSignature(policy2);
            vhdDestUri += destinationBlobToken2;
            return vhdDestUri;
        }
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:17,代码来源:AddAzureVhdSASUriTest.cs

示例2: GetAzureVmSasUri

        private string GetAzureVmSasUri(string vmImageName)
        {
            string mediaLinkUri = null;
            Uri uri = null;
            StorageManagementClient storageClient = null;
            string storageAccountName = null;
            StorageAccountGetKeysResponse getKeysResponse = null;
            ErrorRecord er = null;
            StorageCredentials credentials = null;
            SharedAccessBlobPolicy accessPolicy = null;
            CloudPageBlob pageBlob = null;
            string sas = null;

            mediaLinkUri = GetImageUri(vmImageName);
            uri = new Uri(mediaLinkUri);
            storageClient = new StorageManagementClient(this.Client.Credentials, this.Client.BaseUri);
            storageAccountName = uri.Authority.Split('.')[0];
            getKeysResponse = storageClient.StorageAccounts.GetKeys(storageAccountName);

            if (getKeysResponse.StatusCode != System.Net.HttpStatusCode.OK)
            {
                er = RemoteAppCollectionErrorState.CreateErrorRecordFromString(
                                        String.Format(Commands_RemoteApp.GettingStorageAccountKeyErrorFormat, getKeysResponse.StatusCode.ToString()),
                                        String.Empty,
                                        Client.TemplateImages,
                                        ErrorCategory.ConnectionError
                                        );

                ThrowTerminatingError(er);
            }

            credentials = new StorageCredentials(storageAccountName, getKeysResponse.SecondaryKey);
            accessPolicy = new SharedAccessBlobPolicy();
            pageBlob = new CloudPageBlob(uri, credentials);

            accessPolicy.Permissions = SharedAccessBlobPermissions.Read;
            accessPolicy.SharedAccessStartTime = DateTime.Now;
            accessPolicy.SharedAccessExpiryTime = DateTime.Now.AddHours(12);

            sas = pageBlob.GetSharedAccessSignature(accessPolicy);

            if (sas == null)
            {
                er = RemoteAppCollectionErrorState.CreateErrorRecordFromString(
                                    Commands_RemoteApp.FailedToGetSasUriError,
                                    String.Empty,
                                    Client.TemplateImages,
                                    ErrorCategory.ConnectionError
                                    );

                ThrowTerminatingError(er);
            }

            return mediaLinkUri + sas;
        }
开发者ID:rbramwell,项目名称:azure-powershell,代码行数:55,代码来源:NewAzureRemoteAppTemplateImage.cs

示例3: Initialize

        public void Initialize()
        {
            vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();
            vmPowershellCmdlets.ImportAzurePublishSettingsFile();
            defaultAzureSubscription = vmPowershellCmdlets.SetDefaultAzureSubscription(Resource.DefaultSubscriptionName);
            Assert.AreEqual(Resource.DefaultSubscriptionName, defaultAzureSubscription.SubscriptionName);
            storageAccountKey = vmPowershellCmdlets.GetAzureStorageAccountKey(defaultAzureSubscription.CurrentStorageAccount);
            Assert.AreEqual(defaultAzureSubscription.CurrentStorageAccount, storageAccountKey.StorageAccountName);

            destination = string.Format(@"http://{0}.blob.core.windows.net/vhdstore/{1}", defaultAzureSubscription.CurrentStorageAccount, Utilities.GetUniqueShortName("PSTestAzureVhd"));
            patchDestination = string.Format(@"http://{0}.blob.core.windows.net/vhdstore/{1}", defaultAzureSubscription.CurrentStorageAccount, Utilities.GetUniqueShortName("PSTestAzureVhd"));

            destinationSasUri = string.Format(@"http://{0}.blob.core.windows.net/vhdstore/{1}", defaultAzureSubscription.CurrentStorageAccount, Utilities.GetUniqueShortName("PSTestAzureVhd"));
            patchDestinationSasUri = string.Format(@"http://{0}.blob.core.windows.net/vhdstore/{1}", defaultAzureSubscription.CurrentStorageAccount, Utilities.GetUniqueShortName("PSTestAzureVhd"));
            var destinationBlob = new CloudPageBlob(new Uri(destinationSasUri), new StorageCredentials(storageAccountKey.StorageAccountName, storageAccountKey.Primary));
            var patchDestinationBlob = new CloudPageBlob(new Uri(patchDestinationSasUri), new StorageCredentials(storageAccountKey.StorageAccountName, storageAccountKey.Primary));
            var policy = new SharedAccessBlobPolicy()
            {
                Permissions =
                    SharedAccessBlobPermissions.Delete |
                    SharedAccessBlobPermissions.Read |
                    SharedAccessBlobPermissions.Write |
                    SharedAccessBlobPermissions.List,
                SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromHours(1)
            };
            var destinationBlobToken = destinationBlob.GetSharedAccessSignature(policy);
            var patchDestinationBlobToken = patchDestinationBlob.GetSharedAccessSignature(policy);
            destinationSasUri += destinationBlobToken;
            patchDestinationSasUri += patchDestinationBlobToken;

            blobUrlRoot = string.Format(@"http://{0}.blob.core.windows.net/", defaultAzureSubscription.CurrentStorageAccount);

            perfFile = "perf.csv";
        }
开发者ID:bielawb,项目名称:azure-sdk-tools,代码行数:34,代码来源:AddAzureVhdTest.cs


注:本文中的Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob.GetSharedAccessSignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。