Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] cloudshell issue new-AZStroageContainer not working #369

Open
jileary23 opened this issue Dec 14, 2023 · 2 comments
Open

[BUG] cloudshell issue new-AZStroageContainer not working #369

jileary23 opened this issue Dec 14, 2023 · 2 comments
Labels
bug Something isn't working Priority 3

Comments

@jileary23
Copy link

jileary23 commented Dec 14, 2023

To Reproduce

# Sign in to your Azure account.
Connect-AzAccount

# Set variables.
$rgName = "<resource-group>"
$srcAccountName = "<source-storage-account>"
$destAccountName = "<destination-storage-account>"
$srcContainerName1 = "source-container1"
$destContainerName1 = "dest-container1"
$srcContainerName2 = "source-container2"
$destContainerName2 = "dest-container2"

# Enable blob versioning and change feed on the source account.
Update-AzStorageBlobServiceProperty -ResourceGroupName $rgName `
    -StorageAccountName $srcAccountName `
    -EnableChangeFeed $true `
    -IsVersioningEnabled $true

# Enable blob versioning on the destination account.
Update-AzStorageBlobServiceProperty -ResourceGroupName $rgName `
    -StorageAccountName $destAccountName `
    -IsVersioningEnabled $true

# List the service properties for both accounts.
Get-AzStorageBlobServiceProperty -ResourceGroupName $rgName `
    -StorageAccountName $srcAccountName
Get-AzStorageBlobServiceProperty -ResourceGroupName $rgName `
    -StorageAccountName $destAccountName

# Create containers in the source and destination accounts.
Get-AzStorageAccount -ResourceGroupName $rgName -StorageAccountName $srcAccountName |
    New-AzStorageContainer $srcContainerName1
Get-AzStorageAccount -ResourceGroupName $rgName -StorageAccountName $destAccountName |
    New-AzStorageContainer $destContainerName1
Get-AzStorageAccount -ResourceGroupName $rgName -StorageAccountName $srcAccountName |
    New-AzStorageContainer $srcContainerName2
Get-AzStorageAccount -ResourceGroupName $rgName -StorageAccountName $destAccountName |
    New-AzStorageContainer $destContainerName2

# Define replication rules for each container.
$rule1 = New-AzStorageObjectReplicationPolicyRule -SourceContainer $srcContainerName1 `
    -DestinationContainer $destContainerName1 `
    -PrefixMatch b
$rule2 = New-AzStorageObjectReplicationPolicyRule -SourceContainer $srcContainerName2 `
    -DestinationContainer $destContainerName2  `
    -MinCreationTime 2021-09-01T00:00:00Z

# Create the replication policy on the destination account.
$destPolicy = Set-AzStorageObjectReplicationPolicy -ResourceGroupName $rgName `
    -StorageAccountName $destAccountName `
    -PolicyId default `
    -SourceAccount $srcAccountName `
    -Rule $rule1,$rule2

# Create the same policy on the source account.
Set-AzStorageObjectReplicationPolicy -ResourceGroupName $rgName `
    -StorageAccountName $srcAccountName `
    -InputObject $destPolicy```

Observed Behavior

New-AzStorageContainer: This request is not authorized to perform this operation.                                       
RequestId:c8e6af7c-101e-0030-21c6-2ed069000000
Time:2023-12-14T19:49:49.7620591Z
Status: 403 (This request is not authorized to perform this operation.)
ErrorCode: AuthorizationFailure

Content:
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthorizationFailure</Code><Message>This request is not authorized to perform this operation.
RequestId:c8e6af7c-101e-0030-21c6-2ed069000000
Time:2023-12-14T19:49:49.7620591Z</Message></Error>

Headers:
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: c8e6af7c-101e-0030-21c6-2ed069000000
x-ms-client-request-id: c972ad2d-f55a-4fb7-8f74-fc0b88730142
x-ms-error-code: AuthorizationFailure
Date: Thu, 14 Dec 2023 19:49:49 GMT
Content-Length: 246
Content-Type: application/xml

Expected behavior

create a storage container. I ran the same commands in VS code to my subscription and had no issues. But using cloudshell it didnt work.

Is this specific to Cloud Shell?

Yes. Tested the same script in VS code and didnt have this issue.

Interface information

How are you accessing Cloud Shell - https://portal.azure.com,

Additional context

Add any other context about the problem here.

@jileary23 jileary23 added bug Something isn't working Triage-needed Triage needed by Cloud Shell team labels Dec 14, 2023
@mbifeld
Copy link
Member

mbifeld commented Apr 9, 2024

Does it work if you run 'az login' in Cloud Shell prior to running the command?

@mbifeld mbifeld added Priority 3 and removed Triage-needed Triage needed by Cloud Shell team labels Apr 9, 2024
@jileary23
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority 3
Projects
None yet
Development

No branches or pull requests

2 participants