Skip to content

Commit

Permalink
Merge pull request #6936 from alexandair/patch-31
Browse files Browse the repository at this point in the history
Update storage-powershell-guide-full.md
  • Loading branch information
tynevi authored Jul 12, 2016
2 parents ceb18e3 + 75c35d7 commit de949da
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions articles/storage/storage-powershell-guide-full.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ See [Assigning administrator roles in Azure Active Directory (Azure AD)](https:/

#begin
# Update with the name of your subscription.
$SubscriptionName="YourSubscriptionName"
$SubscriptionName = "YourSubscriptionName"

# Give a name to your new storage account. It must be lowercase!
$StorageAccountName="yourstorageaccountname"
$StorageAccountName = "yourstorageaccountname"

# Choose "West US" as an example.
$Location = "West US"
Expand Down Expand Up @@ -138,14 +138,14 @@ You need an Azure subscription and account to run the PowerShell cmdlets given i

Azure PowerShell is a module that provides cmdlets to manage Azure through Windows PowerShell. For information on installing and setting up Azure PowerShell, see [How to install and configure Azure PowerShell](../powershell-install-configure.md). We recommend that you download and install or upgrade to the latest Azure PowerShell module before using this guide.

You can run the cmdlets in the Azure PowerShell console, the standard Windows PowerShell console, or the Windows PowerShell Integrated Scripting Environment (ISE). For example, to open an **Azure PowerShell console**, go to the Start menu, type Microsoft Azure PowerShell, right-click and click Run as administrator. To open **Windows PowerShell ISE**, go to the Start menu, type Administrative Tools and click to run it. In the Administrative Tools window, right-click Windows PowerShell ISE, click Run as Administrator.
You can run the cmdlets in the standard Windows PowerShell console or the Windows PowerShell Integrated Scripting Environment (ISE). For example, to open **Windows PowerShell ISE**, go to the Start menu, type Administrative Tools and click to run it. In the Administrative Tools window, right-click Windows PowerShell ISE, click Run as Administrator.

## How to manage storage accounts in Azure

### How to set a default Azure subscription
To manage Azure Storage using Azure PowerShell, you need to authenticate your client environment with Azure via Azure Active Directory Authentication or Certificate-based Authentication. For detailed information, see [How to install and configure Azure PowerShell](../powershell-install-configure.md) tutorial. This guide uses the Azure Active Directory authentication.
To manage Azure Storage using Azure PowerShell, you need to authenticate your client environment with Azure via Azure Active Directory authentication or certificate-based authentication. For detailed information, see [How to install and configure Azure PowerShell](../powershell-install-configure.md) tutorial. This guide uses the Azure Active Directory authentication.

1. In the Azure PowerShell console or in Windows PowerShell ISE, type the following command to add your Azure account to the local PowerShell environment:
1. In Windows PowerShell ISE, type the following command to add your Azure account to the local PowerShell environment:

`Add-AzureAccount`

Expand Down Expand Up @@ -177,7 +177,7 @@ To use Azure storage, you will need a storage account. You can create a new Azur

1. Run the Get-AzureLocation cmdlet to find all the available datacenter locations:

`Get-AzureLocation | format-Table -Property Name, AvailableServices, StorageAccountTypes`
`Get-AzureLocation | Format-Table -Property Name, AvailableServices, StorageAccountTypes`

2. Next, run the New-AzureStorageAccount cmdlet to create a new storage account. The following example creates a new storage account in the "West US" datacenter.

Expand Down Expand Up @@ -233,7 +233,7 @@ Use one of the following three ways to create a storage context:

For more information on how to configure a storage connection string, see [Configuring Connection Strings](storage-configure-connection-string.md).

Now that you have set up your computer and learned how to manage subscriptions and storage accounts using Azure PowerShell. Go to the next section to learn how to manage Azure blobs and blob snapshots.
Now that you have set up your computer and learned how to manage subscriptions and storage accounts using Azure PowerShell, go to the next section to learn how to manage Azure blobs and blob snapshots.

### How to retrieve and regenerate Azure storage keys

Expand Down Expand Up @@ -316,7 +316,7 @@ You can copy blobs across storage accounts and regions asynchronously. The follo
Note that this example performs an asynchronous copy. You can monitor the status of each copy by running the [Get-AzureStorageBlobCopyState](http://msdn.microsoft.com/library/azure/dn806406.aspx) cmdlet.

### How to copy blobs from a secondary location
You can copy blobs from the secondary locatioon of a RA-GRS enabled account.
You can copy blobs from the secondary location of a RA-GRS-enabled account.

#define secondary storage context using a connection string constructed from secondary endpoints.
$SrcContext = New-AzureStorageContext -ConnectionString "DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***;BlobEndpoint=http://***-secondary.blob.core.windows.net;FileEndpoint=http://***-secondary.file.core.windows.net;QueueEndpoint=http://***-secondary.queue.core.windows.net; TableEndpoint=http://***-secondary.table.core.windows.net;"
Expand Down Expand Up @@ -388,12 +388,12 @@ You can copy a snapshot of a blob to restore the snapshot. For detailed informat
#Copy the snapshot to another container.
Start-AzureStorageBlobCopy –Context $Ctx -ICloudBlob $snap -DestBlob $DestBlobName -DestContainer $DestContainerName

Now that you have learned how to manage Azure blobs and blob snapshots with Azure PowerShell. Go to the next section to learn how to manage tables, queues, and files.
Now that you have learned how to manage Azure blobs and blob snapshots with Azure PowerShell, go to the next section to learn how to manage tables, queues, and files.

## How to manage Azure tables and table entities
Azure Table storage service is a NoSQL datastore, which you can use to store and query huge sets of structured, non-relational data. The main components of the service are tables, entities, and properties. A table is a collection of entities. An entity is a set of properties. Each entity can have up to 252 properties, which are all name-value pair. This section assumes that you are already familiar with the Azure Table Storage Service concepts. For detailed information, see [Understanding the Table Service Data Model](http://msdn.microsoft.com/library/azure/dd179338.aspx) and [Get started with Azure Table storage using .NET](storage-dotnet-how-to-use-tables.md).
Azure Table storage service is a NoSQL datastore, which you can use to store and query huge sets of structured, non-relational data. The main components of the service are tables, entities, and properties. A table is a collection of entities. An entity is a set of properties. Each entity can have up to 252 properties, which are all name-value pairs. This section assumes that you are already familiar with the Azure Table Storage Service concepts. For detailed information, see [Understanding the Table Service Data Model](http://msdn.microsoft.com/library/azure/dd179338.aspx) and [Get started with Azure Table storage using .NET](storage-dotnet-how-to-use-tables.md).

In the following sub sections, you’ll learn how to manage Azure Table storage service using Azure PowerShell. The scenarios covered include **creating**, **deleting**, and **retrieving** **tables**, as well as **adding**, **querying**, and **deleting table entities**.
In the following subsections, you’ll learn how to manage Azure Table storage service using Azure PowerShell. The scenarios covered include **creating**, **deleting**, and **retrieving** **tables**, as well as **adding**, **querying**, and **deleting table entities**.

### How to create a table
Every table must reside in an Azure storage account. The following example demonstrates how to create a table in Azure Storage. The example first establishes a connection to Azure Storage using the storage account context, which includes the storage account name and its access key. Next, it uses the [New-AzureStorageTable](http://msdn.microsoft.com/library/azure/dn806417.aspx) cmdlet to create a table in Azure Storage.
Expand Down Expand Up @@ -481,7 +481,7 @@ To query a table, use the [Microsoft.WindowsAzure.Storage.Table.TableQuery](http
#Define the storage account and context.
$StorageAccountName = "yourstorageaccount"
$StorageAccountKey = Get-AzureStorageKey -StorageAccountName $StorageAccountName
$Ctx = New-AzureStorageContext –StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey.Primary;
$Ctx = New-AzureStorageContext –StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey.Primary
$TableName = "Employees"

#Get a reference to a table.
Expand All @@ -505,7 +505,7 @@ To query a table, use the [Microsoft.WindowsAzure.Storage.Table.TableQuery](http
$entities = $table.CloudTable.ExecuteQuery($query)

#Display entity properties with the table format.
$entities | Format-Table PartitionKey, RowKey, @{ Label = "Name"; Expression={$_.Properties["Name"].StringValue}}, @{ Label = "ID"; Expression={$_.Properties[“ID”].Int32Value}} -AutoSize
$entities | Format-Table PartitionKey, RowKey, @{ Label = "Name"; Expression={$_.Properties["Name"].StringValue}}, @{ Label = "ID"; Expression={$_.Properties["ID"].Int32Value}} -AutoSize

#### How to delete table entities
You can delete an entity using its partition and row keys. The following example assumes that you’ve already run the script given in the How to add entities section of this guide. The example first establishes a connection to Azure Storage using the storage context, which includes the storage account name and its access key. Next, it tries to retrieve the previously created “Employees” table using the [Get-AzureStorageTable](http://msdn.microsoft.com/library/azure/dn806411.aspx) cmdlet. If the table exists, the example calls the [Microsoft.WindowsAzure.Storage.Table.TableOperation.Retrieve](http://msdn.microsoft.com/library/azure/microsoft.windowsazure.storage.table.tableoperation.retrieve.aspx) method to retrieve an entity based on its partition and row key values. Then, pass the entity to the [Microsoft.WindowsAzure.Storage.Table.TableOperation.Delete](http://msdn.microsoft.com/library/azure/microsoft.windowsazure.storage.table.tableoperation.delete.aspx) method to delete.
Expand All @@ -523,11 +523,12 @@ You can delete an entity using its partition and row keys. The following example
if ($table -ne $null) {
#Together the PartitionKey and RowKey uniquely identify every
#entity within a table.
$tableResult = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::Retrieve(Partition2, "Row1"))
$entity = $tableResult.Result;
$tableResult = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::Retrieve("Partition2", "Row1"))
$entity = $tableResult.Result
if ($entity -ne $null)
{
#Delete the entity.$table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::Delete($entity))
#Delete the entity.
$table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::Delete($entity))
}
}

Expand Down Expand Up @@ -638,7 +639,7 @@ For more information, see [Shared Access Signatures: Understanding the SAS Model

In the next sections, you will learn how to create a shared access signature token and stored access policy for Azure tables. Azure PowerShell provides similar cmdlets for containers, blobs, and queues as well. To run the scripts in this section, download the [Azure PowerShell version 0.8.14](http://go.microsoft.com/?linkid=9811175&clcid=0x409) or later.

### How to create a policy based Shared Access Signature token
### How to create a policy-based Shared Access Signature token
Use the New-AzureStorageTableStoredAccessPolicy cmdlet to create a new stored access policy. Then, call the [New-AzureStorageTableSASToken](http://msdn.microsoft.com/library/azure/dn806400.aspx) cmdlet to create a new policy-based shared access signature token for an Azure Storage table.

$policy = "policy1"
Expand Down

0 comments on commit de949da

Please sign in to comment.