コード例 #1
0
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess("ServiceProperties", VerbsCommon.Set))
            {
                if (ServiceType != StorageServiceType.Table)
                {
                    StorageClient.ServiceProperties serviceProperties = Channel.GetStorageServiceProperties(ServiceType, GetRequestOptions(ServiceType), OperationContext);

                    serviceProperties.DefaultServiceVersion = this.DefaultServiceVersion;

                    Channel.SetStorageServiceProperties(ServiceType, serviceProperties,
                                                        GetRequestOptions(ServiceType), OperationContext);

                    if (PassThru)
                    {
                        WriteObject(new PSSeriviceProperties(serviceProperties));
                    }
                }
                else //Table use old XSCL
                {
                    StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);

                    if (!tableChannel.IsTokenCredential)
                    {
                        XTable.ServiceProperties serviceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);

                        if (!string.IsNullOrEmpty(DefaultServiceVersion))
                        {
                            serviceProperties.DefaultServiceVersion = this.DefaultServiceVersion;
                        }

                        tableChannel.SetStorageTableServiceProperties(serviceProperties,
                                                                      GetTableRequestOptions(), TableOperationContext);

                        if (PassThru)
                        {
                            WriteObject(new PSSeriviceProperties(serviceProperties));
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Updating default service version is not supported while using OAuth.");
                    }
                }
            }
        }
コード例 #2
0
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess("ServiceProperties", VerbsCommon.Set))
            {
                if (ServiceType != StorageServiceType.Table)
                {
                    StorageClient.ServiceProperties serviceProperties = Channel.GetStorageServiceProperties(ServiceType, GetRequestOptions(ServiceType), OperationContext);

                    serviceProperties.DefaultServiceVersion = this.DefaultServiceVersion;

                    Channel.SetStorageServiceProperties(ServiceType, serviceProperties,
                                                        GetRequestOptions(ServiceType), OperationContext);

                    if (PassThru)
                    {
                        WriteObject(new PSSeriviceProperties(serviceProperties));
                    }
                }
                else //Table use old XSCL
                {
                    StorageTableManagement   tableChannel      = new StorageTableManagement(Channel.StorageContext);
                    XTable.ServiceProperties serviceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);

                    if (!string.IsNullOrEmpty(DefaultServiceVersion))
                    {
                        serviceProperties.DefaultServiceVersion = this.DefaultServiceVersion;
                    }

                    tableChannel.SetStorageTableServiceProperties(serviceProperties,
                                                                  GetTableRequestOptions(), TableOperationContext);

                    if (PassThru)
                    {
                        WriteObject(new PSSeriviceProperties(serviceProperties));
                    }
                }
            }
        }
コード例 #3
0
        public override void ExecuteCmdlet()
        {
            if (StorageServiceType.File == ServiceType)
            {
                throw new PSInvalidOperationException(Resources.FileNotSupportLogging);
            }

            if (ServiceType != StorageServiceType.Table)
            {
                StorageClient.ServiceProperties currentServiceProperties = Channel.GetStorageServiceProperties(ServiceType, GetRequestOptions(ServiceType), OperationContext);

                // Premium Account not support classic metrics and logging
                if (currentServiceProperties.Logging == null)
                {
                    AccountProperties accountProperties = Channel.GetAccountProperties();
                    if (accountProperties.SkuName.Contains("Premium"))
                    {
                        throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "This Storage account doesn't support Classic Logging, since it’s a Premium Storage account: {0}", Channel.StorageContext.StorageAccountName));
                    }
                }

                StorageClient.ServiceProperties serviceProperties = new StorageClient.ServiceProperties();
                serviceProperties.Clean();
                serviceProperties.Logging = currentServiceProperties.Logging;

                UpdateServiceProperties(serviceProperties.Logging);

                Channel.SetStorageServiceProperties(ServiceType, serviceProperties,
                                                    GetRequestOptions(ServiceType), OperationContext);

                if (PassThru)
                {
                    WriteObject(serviceProperties.Logging);
                }
            }
            else //Table use old XSCL
            {
                StorageTableManagement   tableChannel             = new StorageTableManagement(Channel.StorageContext);
                XTable.ServiceProperties currentServiceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);

                // Premium Account not support classic metrics and logging
                if (currentServiceProperties.Logging == null)
                {
                    AccountProperties accountProperties = Channel.GetAccountProperties();
                    if (accountProperties.SkuName.Contains("Premium"))
                    {
                        throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "This Storage account doesn't support Classic Logging, since it’s a Premium Storage account: {0}", Channel.StorageContext.StorageAccountName));
                    }
                }

                XTable.ServiceProperties serviceProperties = new XTable.ServiceProperties();
                serviceProperties.Clean();
                serviceProperties.Logging = currentServiceProperties.Logging;

                UpdateTableServiceProperties(serviceProperties.Logging);

                tableChannel.SetStorageTableServiceProperties(serviceProperties,
                                                              GetTableRequestOptions(), TableOperationContext);

                if (PassThru)
                {
                    WriteObject(serviceProperties.Logging);
                }
            }
        }