Edit

Share via


Set-AzStorageLocalUser

Creates or updates a specified local user in a storage account.

Syntax

AccountName (Default)

Set-AzStorageLocalUser
    [-ResourceGroupName] <String>
    [-StorageAccountName] <String>
    -UserName <String>
    [-HomeDirectory <String>]
    [-SshAuthorizedKey <PSSshPublicKey[]>]
    [-PermissionScope <PSPermissionScope[]>]
    [-HasSharedKey <Boolean>]
    [-HasSshKey <Boolean>]
    [-HasSshPassword <Boolean>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

AccountObject

Set-AzStorageLocalUser
    -StorageAccount <PSStorageAccount>
    -UserName <String>
    [-HomeDirectory <String>]
    [-SshAuthorizedKey <PSSshPublicKey[]>]
    [-PermissionScope <PSPermissionScope[]>]
    [-HasSharedKey <Boolean>]
    [-HasSshKey <Boolean>]
    [-HasSshPassword <Boolean>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Set-AzStorageLocalUser cmdlet creates or updates a specified local user in a storage account. To run this cmdlet, the storage account must has already set EnableLocalUser as true.

Examples

Example 1: Create or update a local user

$sshkey1 = New-AzStorageLocalUserSshPublicKey -Key "ssh-rsa base64encodedkey=" -Description "sshpublickey name1"

$permissionScope1 = New-AzStorageLocalUserPermissionScope -Permission rw -Service blob -ResourceName container1

$localuser = Set-AzStorageLocalUser -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -UserName testuser1 -HomeDirectory "/" -SshAuthorizedKey $sshkey1 -PermissionScope $permissionScope1 -HasSharedKey $true -HasSshKey $true -HasSshPassword $true

$localuser

   ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount

Name      Sid                                          HomeDirectory HasSharedKey HasSshKey HasSshPassword PermissionScopes
----      ---                                          ------------- ------------ --------- -------------- ----------------
testuser1 S-1-2-0-0000000000-000000000-0000000000-0000 /             True         True      True           [container1]

$localuser.SshAuthorizedKeys

Description       Key
-----------       ---
sshpublickey name1 ssh-rsa base64encodedkey=

$localuser.PermissionScopes

Permissions Service ResourceName
----------- ------- ------------
rw          blob    container1

The first command creates a local SSH public key object. Note that the key follows the format of <algorithm> <data> where data is the base64 encoded contents of the public key. The second command creates a local permission scope object that defines the container level access for the local user. The third command creates or updates the local user, using the local objects from the first 2 commands. The final command shows the local user properties.

Example 2: Create or update a local user by input permission scope and ssh key with json

Set-AzStorageLocalUser -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -UserName testuser1 -HomeDirectory "/" -HasSharedKey $true -HasSshKey $true -HasSshPassword $true `
            -SshAuthorizedKey (@{
                Description="sshpublickey name1";
                Key="ssh-rsa base64encodedkey=";
            },
            @{
                Description="sshpublickey name2";
                Key="ssh-rsa otherbase64encodedkey=";
            }) `
            -PermissionScope (@{
                Permissions="rw";
                Service="blob";
                ResourceName="container1";
            },
            @{
                Permissions="rwd";
                Service="share";
                ResourceName="share1";
            })
ResourceGroupName: weitry, StorageAccountName: weisftp3

Name      Sid                                          HomeDirectory HasSharedKey HasSshKey HasSshPassword PermissionScopes
----      ---                                          ------------- ------------ --------- -------------- ----------------
testuser1 S-1-2-0-0000000000-000000000-0000000000-0000 /             True         True      True           [container1,...]

This command creates or updates a local user by input permission scope and ssh key with json.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-HasSharedKey

Whether shared key exists. Set it to false to remove existing shared key.

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-HasSshKey

Whether SSH key exists. Set it to false to remove existing SSH key.

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-HasSshPassword

Whether SSH password exists. Set it to false to remove existing SSH password.

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-HomeDirectory

Local user home directory

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PermissionScope

The permission scopes of the local user. Get the object with New-AzStorageLocalUserPermissionScope cmdlet.

Parameter properties

Type:

PSPermissionScope[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

Resource Group Name.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AccountName
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SshAuthorizedKey

Local user ssh authorized keys for SFTP. Get the object with New-AzStorageLocalUserSshPublicKey cmdlet.

Parameter properties

Type:

PSSshPublicKey[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StorageAccount

Storage account object

Parameter properties

Type:PSStorageAccount
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AccountObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-StorageAccountName

Storage Account Name.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AccountName

Parameter sets

AccountName
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-UserName

The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Name

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

PSStorageAccount

Outputs

PSLocalUser