Skip to content

Commit

Permalink
Azure Storage Track 2 client libraries (#6256)
Browse files Browse the repository at this point in the history
* Azure Storage Track 2 client libraries

* Update with PR feedback

Removed the Shared projects that were breaking the build and replaced them
with folders that I include/exclude in the .csproj files.

Moved the swagger and generator files out of the top level, moved the generated
code into a directory.

Removed build properties that weren't needed and reordered things to read
a little simpler.

* Adding doc warden exclusions and updating links (+ creating targets)

* Add the service version to the READMEs and a doc-warden exclusion

* Be less aggressive about which XML files get copied for testing

as they're never relevant to server builds

* Adding Live test categtory to exclude for the full framework

* Disabling test parallelizaton temporarily
  • Loading branch information
tg-msft authored May 15, 2019
1 parent 7d741a2 commit e8b907f
Show file tree
Hide file tree
Showing 173 changed files with 73,647 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ tools/*.dll
# Sensitive files
*.keys
*.pfx
sdk/storage/Azure.Storage.Common/tests/Shared/TestConfigurations.xml

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
Expand Down Expand Up @@ -142,4 +143,8 @@ build.out
# Azure Project
csx/
*.GhostDoc.xml
pingme.txt
pingme.txt

# TS/Node files
dist/
node_modules/
5 changes: 5 additions & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ known_presence_issues:
- ['sdk/hdinsight/Microsoft.Azure.HDInsight.Job','#5499']
- ['sdk/applicationinsights/Microsoft.Azure.ApplicationInsights','#5499']
- ['sdk/containerregistry/Microsoft.Azure.ContainerRegistry','#5499']
- ['sdk/storage','azure-sdk-tools/issues/43']
known_content_issues:
- ['README.md','Root readme']
- ['sdk/keyvault/Microsoft.Azure.KeyVault/README.md','#5499']
Expand All @@ -31,6 +32,10 @@ known_content_issues:
- ['sdk/appconfiguration/Azure.ApplicationModel.Configuration/README.md','#5499']
- ['sdk/appconfiguration/Azure.ApplicationModel.Configuration/tests/Readme.md','#5499']
- ['sdk/core/Azure.Core/README.md','#5499']
- ['sdk/storage/Azure.Storage.Blobs/swagger/readme.md','azure-sdk-tools/issues/42']
- ['sdk/storage/Azure.Storage.Files/swagger/readme.md','azure-sdk-tools/issues/42']
- ['sdk/storage/Azure.Storage.Queues/swagger/readme.md','azure-sdk-tools/issues/42']
- ['sdk/storage/Azure.Storage.Common/swagger/Generator/readme.md','azure-sdk-tools/issues/42']
# .net climbs upwards. placing these to prevent assigning readmes to the wrong project
package_indexing_exclusion_list:
- 'AutoRest-AzureDotNetSDK'
Expand Down
9 changes: 7 additions & 2 deletions sdk/core/Azure.Core/src/ResponseExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public static RequestFailedException CreateRequestFailedException(this Response
}

public static async Task<RequestFailedException> CreateRequestFailedExceptionAsync(string message, Response response, bool async)
{
message = await CreateRequestFailedMessageAsync(message, response, async);
return new RequestFailedException(response.Status, message);
}

public static async Task<string> CreateRequestFailedMessageAsync(string message, Response response, bool async)
{
StringBuilder messageBuilder = new StringBuilder()
.AppendLine(message)
Expand All @@ -59,7 +65,6 @@ public static async Task<RequestFailedException> CreateRequestFailedExceptionAsy
}
}


messageBuilder
.AppendLine()
.AppendLine("Headers:");
Expand All @@ -68,7 +73,7 @@ public static async Task<RequestFailedException> CreateRequestFailedExceptionAsy
messageBuilder.AppendLine($"{responseHeader.Name}: {responseHeader.Value}");
}

return new RequestFailedException(response.Status, messageBuilder.ToString());
return messageBuilder.ToString();
}
}
}
165 changes: 165 additions & 0 deletions sdk/storage/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
###############################
# Core EditorConfig Options #
###############################

root = true

# All files
[*]
indent_style = space

# Code files
[*.cs]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom

###############################
# .NET Coding Conventions #
###############################

# Organize usings
dotnet_sort_system_directives_first = true

# this. preferences
dotnet_style_qualification_for_field = true : warning
dotnet_style_qualification_for_property = true : warning
dotnet_style_qualification_for_method = true : warning
dotnet_style_qualification_for_event = true : warning

# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true : error
dotnet_style_predefined_type_for_member_access = false : error

# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity : suggestion
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity : suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity : suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary : suggestion

# Modifier preferences
dotnet_style_require_accessibility_modifiers = never : suggestion
dotnet_style_readonly_field = true : error

# Expression-level preferences
dotnet_style_object_initializer = true : suggestion
dotnet_style_collection_initializer = true : suggestion
dotnet_style_explicit_tuple_names = true : suggestion
dotnet_style_null_propagation = true : suggestion
dotnet_style_coalesce_expression = true : suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true : suggestion
dotnet_style_prefer_inferred_tuple_names = true : error
dotnet_style_prefer_inferred_anonymous_type_member_names = true : suggestion
dotnet_style_prefer_auto_properties = true : suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true : suggestion
dotnet_style_prefer_conditional_expression_over_return = true : suggestion

###############################
# Naming Conventions #
###############################

# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const

###############################
# C# Coding Conventions #
###############################

# var preferences
csharp_style_var_for_built_in_types = true : warning
csharp_style_var_when_type_is_apparent = true : warning
csharp_style_var_elsewhere = true : warning

# Expression-bodied members
csharp_style_expression_bodied_methods = true : suggestion
csharp_style_expression_bodied_constructors = true : suggestion
csharp_style_expression_bodied_operators = true : suggestion
csharp_style_expression_bodied_properties = true : suggestion
csharp_style_expression_bodied_indexers = true : suggestion
csharp_style_expression_bodied_accessors = true : suggestion

# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true : warning
csharp_style_pattern_matching_over_as_with_null_check = true : warning

# Null-checking preferences
csharp_style_throw_expression = true : warning
csharp_style_conditional_delegate_call = true : suggestion

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async : suggestion

# Expression-level preferences
csharp_prefer_braces = true : warning
csharp_style_deconstructed_variable_declaration = true : suggestion
csharp_prefer_simple_default_expression = true : suggestion
csharp_style_pattern_local_over_anonymous_function = true : suggestion
csharp_style_inlined_variable_declaration = true : suggestion

###############################
# C# Formatting Rules #
###############################

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false

# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true


###############################
# Ignore Generated Code #
###############################

[*RestClient.cs]
root = true
dotnet_style_predefined_type_for_locals_parameters_members = true:none
dotnet_style_predefined_type_for_member_access = true:none
dotnet_style_null_propagation = true:none
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:none
csharp_style_var_elsewhere = false:none
csharp_style_inlined_variable_declaration = false:none
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_properties = false:none
csharp_style_expression_bodied_indexers = false:none
csharp_style_expression_bodied_accessors = false:none
dotnet_style_object_initializer = false:none
csharp_style_throw_expression = false:none
dotnet_style_prefer_conditional_expression_over_assignment = false:none
dotnet_style_prefer_conditional_expression_over_return = false:none
Empty file.
Empty file.
118 changes: 118 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Azure Storage Blobs client library for .NET

> Server Version: 2018-11-09
Azure Blob storage is Microsoft's object storage solution for the cloud. Blob
storage is optimized for storing massive amounts of unstructured data.
Unstructured data is data that does not adhere to a particular data model or
definition, such as text or binary data.

[Source code][source] | [Package (NuGet)][package] | [API reference documentation][rest_docs] | [Product documentation][product_docs]

## Getting started
### Install the package
Install the Azure Storage Blobs client library for .NET with [NuGet][nuget]:

```Powershell
Install-Package Azure.Storage.Blobs
```

**Prerequisites**: You must have an [Azure subscription][azure_sub], and a
[Storage Account][storage_account_docs] to use this package.

To create a Storage Account, you can use the [Azure Portal][storage_account_create_portal],
[Azure PowerShell][storage_account_create_ps] or [Azure CLI][storage_account_create_cli]:

## Key concepts
Blob storage is designed for:
- Serving images or documents directly to a browser.
- Storing files for distributed access.
- Streaming video and audio.
- Writing to log files.
- Storing data for backup and restore, disaster recovery, and archiving.
- Storing data for analysis by an on-premises or Azure-hosted service.

## Examples
### Uploading a blob
```c#
string connectionString = <connection_string>;
var service = new BlobServiceClient(connectionString);
var container = service.GetBlobContainerClient("mycontainer");
await container.CreateAsync();

var blob = container.GetBlockBlobClient("myblob");
using (var data = File.OpenRead("Samples/SampleSource.txt"))
{
await blob.UploadAsync(data);
}
```

### Downloading a blob
```c#
string connectionString = <connection_string>;
var service = new BlobServiceClient(connectionString);
var container = service.GetBlobContainerClient("mycontainer");
var blob = container.GetBlockBlobClient("myblob");

var download = await blob.DownloadAsync();
using (var file = File.Create("BlockDestination.txt"))
{
await download.Value.Content.CopyToAsync(file);
}
```

### Enumerating blobs
```c#
string connectionString = <connection_string>;
var service = new BlobServiceClient(connectionString);
var container = service.GetBlobContainerClient("mycontainer");

string marker;
do
{
var response = await container.ListBlobsFlatSegmentAsync(marker);
foreach (var blob in response.Value.BlobItems)
{
Console.WriteLine(blob.Name);
}
marker = response.Value.NextMarker;
}
while (!string.IsNullOrEmpty(marker));
```

## Troubleshooting
All Blob service operations will throw a
[StorageRequestFailedException][StorageRequestFailedException] on failure with
helpful [`ErrorCode`s][error_codes].

## Next steps
Get started with our [Blob samples][samples].

## Contributing
This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution. For
details, visit https://cla.microsoft.com.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [[email protected]](mailto:[email protected]) with any
additional questions or comments.

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net%2Fsdk%2Fstorage%2FAzure.Storage.Blobs%2FREADME.png)

<!-- LINKS -->
[source]: https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/storage/Azure.Storage.Blobs/src
[package]: https://www.nuget.org/packages/Azure.Storage.Blobs/
[rest_docs]: https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api
[product_docs]: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-overview
[nuget]: https://www.nuget.org/
[storage_account_docs]: https://docs.microsoft.com/en-us/azure/storage/common/storage-account-overview
[storage_account_create_ps]: https://docs.microsoft.com/en-us/azure/storage/common/storage-quickstart-create-account?tabs=azure-powershell
[storage_account_create_cli]: https://docs.microsoft.com/en-us/azure/storage/common/storage-quickstart-create-account?tabs=azure-cli
[storage_account_create_portal]: https://docs.microsoft.com/en-us/azure/storage/common/storage-quickstart-create-account?tabs=azure-portal
[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_sub]: https://azure.microsoft.com/free/
[StorageRequestFailedException]: https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/storage/Azure.Storage.Common/src/StorageRequestFailedException.cs
[error_codes]: https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes
[samples]: tests/Samples/
Loading

0 comments on commit e8b907f

Please sign in to comment.