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


C# IStorageBlobManagement.SetContainerPermissions方法代码示例

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


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

示例1: RemoveAzureContainerStoredAccessPolicy

        internal bool RemoveAzureContainerStoredAccessPolicy(IStorageBlobManagement localChannel, string containerName, string policyName)
        {
            bool success = false;
            string result = string.Empty;

            //Get existing permissions
            CloudBlobContainer container = localChannel.GetContainerReference(containerName);
            BlobContainerPermissions blobContainerPermissions = localChannel.GetContainerPermissions(container);

            //remove the specified policy
            if (!blobContainerPermissions.SharedAccessPolicies.Keys.Contains(policyName))
            {
                throw new ResourceNotFoundException(String.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName));
            }

            if (ShouldProcess(policyName, "Remove policy"))
            {
                blobContainerPermissions.SharedAccessPolicies.Remove(policyName);
                localChannel.SetContainerPermissions(container, blobContainerPermissions);
                success = true;
            }

            return success;
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:24,代码来源:RemoveAzureStorageContainerStoredAccessPolicy.cs

示例2: SetAzureContainerStoredAccessPolicy

        internal string SetAzureContainerStoredAccessPolicy(IStorageBlobManagement localChannel, string containerName, string policyName, DateTime? startTime, DateTime? expiryTime, string permission, bool noStartTime, bool noExpiryTime)
        {
            //Get existing permissions
            CloudBlobContainer container = localChannel.GetContainerReference(containerName);
            BlobContainerPermissions blobContainerPermissions = localChannel.GetContainerPermissions(container);

            //Set the policy with new value
            if (!blobContainerPermissions.SharedAccessPolicies.Keys.Contains(policyName))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName));
            }

            SharedAccessBlobPolicy policy = blobContainerPermissions.SharedAccessPolicies[policyName];
            AccessPolicyHelper.SetupAccessPolicy<SharedAccessBlobPolicy>(policy, startTime, expiryTime, permission, noStartTime, noExpiryTime);
            blobContainerPermissions.SharedAccessPolicies[policyName] = policy;

            //Set permission back to container
            localChannel.SetContainerPermissions(container, blobContainerPermissions);
            WriteObject(AccessPolicyHelper.ConstructPolicyOutputPSObject<SharedAccessBlobPolicy>(blobContainerPermissions.SharedAccessPolicies, policyName));
            return policyName;
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:21,代码来源:SetAzureStorageContainerStoredAccessPolicy.cs

示例3: CreateAzureContainerStoredAccessPolicy

        internal string CreateAzureContainerStoredAccessPolicy(IStorageBlobManagement localChannel, string containerName, string policyName, DateTime? startTime, DateTime? expiryTime, string permission)
        {
            if (!NameUtil.IsValidStoredAccessPolicyName(policyName))
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Resources.InvalidAccessPolicyName, policyName));
            }

            //Get existing permissions
            CloudBlobContainer container = localChannel.GetContainerReference(containerName);
            BlobContainerPermissions blobContainerPermissions = localChannel.GetContainerPermissions(container);

            //Add new policy
            if (blobContainerPermissions.SharedAccessPolicies.Keys.Contains(policyName))
            {
                throw new ResourceAlreadyExistException(String.Format(CultureInfo.CurrentCulture, Resources.PolicyAlreadyExists, policyName));
            }

            SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
            AccessPolicyHelper.SetupAccessPolicy<SharedAccessBlobPolicy>(policy, startTime, expiryTime, permission);
            blobContainerPermissions.SharedAccessPolicies.Add(policyName, policy);

            //Set permissions back to container
            localChannel.SetContainerPermissions(container, blobContainerPermissions);
            return policyName;
        }
开发者ID:Hamza2404,项目名称:azure-powershell,代码行数:25,代码来源:NewAzureStorageContainerStoredAccessPolicy.cs


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