Trying to copy a file or folder within same container in ADLS Gen2.
I generated SAS key at account level, created context and could create new container, folder but can't move files or folder. Am I missing anything?
Error:
Move-AzDataLakeGen2Item : Server failed to authenticate the request. Please refer to the information in the www-authenticate header.
RequestId:f2739649-201f-0057-0f68-196d84000000
Time:2021-03-15T07:00:16.5814369Z
Status: 401 (Server failed to authenticate the request. Please refer to the information in the www-authenticate header.)
ErrorCode: NoAuthenticationInformation
Headers:
x-ms-error-code: NoAuthenticationInformation
x-ms-request-id: f2739649-201f-0057-0f68-196d84000000
x-ms-version: 2020-04-08
x-ms-client-request-id: da2ca9a0-b331-44c1-b8aa-2d8fd61bec44
Content-Length: 250
Content-Type: application/json;charset=utf-8
Date: Mon, 15 Mar 2021 07:00:16 GMT
Server: Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0
WWW-Authenticate: REDACTED
At line:1 char:1
+ Move-AzDataLakeGen2Item -Context $ctx -FileSystem "newcontainer" -Pat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Move-AzDataLakeGen2Item], RequestFailedException
+ FullyQualifiedErrorId : RequestFailedException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.MoveAzDataLakeGen2ItemCommand
PowerShell code:
$ctx = New-AzStorageContext -StorageAccountName "myadlsgen2" -SasToken "?sv=2020-02-10&ss=b&srt=sco&sp=rwdlacx&se=2021-03-16T13:27:14Z&st=2021-03-15T05:27:14Z&spr=https&sig=..."
New-AzStorageContext -StorageAccountName "myadlsgen2" -SasToken $ctx
#below works
Get-AzDatalakeGen2FileSystem -Context $ctx -Name "vccontainer"
New-AzStorageContainer -Context $ctx -Name "newcontainer"
#below fails
Move-AzDataLakeGen2Item -Context $ctx -FileSystem "newcontainer" -Path "Newfolder/" -DestFileSystem "newcontainer" -DestPath "dir/" -Verbose
Related
The following commands were previously working from a local PS session using module Az.ManagedServiceIdentity version 0.7.2, but broke once I updated to 0.7.3, now can't get it to work again even after downgrading the module version. I'd like to use this module from cloud shell ideally but get the same error.
*$uamiRg = (Get-AzResourceGroup -Name *identity*).ResourceGroupName
$uami = Get-AzUserAssignedIdentity -ResourceGroupName $uamiRg -Name "my-uami"*
This used to grab the ID, RG, Name, Location, TenantId, etc. needed to use the User Assigned Managed Identity for assigning Azure Blueprints. Now the 2nd command throws this error:
*Get-AzUserAssignedIdentity : Extended 'versions' can't be converted to a boolean
At line:1 char:1
+ Get-AzUserAssignedIdentity -ResourceGroupName $uamiRg -Verbose -Error ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzUserAssignedIdentity], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ManagedServiceIdentity.UserAssignedIdentities.GetAzureRmUserAssignedIdentityCmdlet*
Debug results:
DEBUG: 5:51:44 AM - GetAzureRmUserAssignedIdentityCmdlet begin processing with ParameterSet 'ResourceGroupParameterSet'.
DEBUG: 5:51:44 AM - using account id ''...
DEBUG: [Common.Authentication]: Authenticating using Account: '', environment: 'AzureCloud', tenant: '***'
DEBUG: [HttpClientOperations]: Adding Header 'Metadata'
DEBUG: Checking Cache request http://localhost:50342/oauth2/token?resource=https%3A%2F%2Fmanagement.core.windows.net%2F&api-version=2018-02-01
DEBUG: Cache Hit
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/***/resourceGroups/***Identity-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-uami?api-version=2015-08-31-preview
Headers:
x-ms-client-request-id : f0c521dd-5e24-400c-acc5-b47e9f1e75f2
Accept-Language : en-US
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Cache-Control : no-cache
Pragma : no-cache
Strict-Transport-Security : max-age=31536000; includeSubDomains
Server : Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 11997
x-ms-request-id : 8164b0a7-a810-4cb0-b5c1-29484e924c3f
x-ms-correlation-request-id : 8164b0a7-a810-4cb0-b5c1-29484e924c3f
x-ms-routing-request-id : EASTUS:20200405T055145Z:8164b0a7-a810-4cb0-b5c1-29484e924c3f
X-Content-Type-Options : nosniff
Date : Sun, 05 Apr 2020 05:51:44 GMT
Body:
{
"error": {
"code": "BadRequest",
"message": "Extended 'versions' can't be converted to a boolean"
}
}
Get-AzUserAssignedIdentity: Extended 'versions' can't be converted to a boolean
DEBUG: AzureQoSEvent: CommandName - Get-AzUserAssignedIdentity; IsSuccess - False; Duration - 00:00:00.2875296;; Exception - Microsoft.Rest.Azure.CloudException: Extended 'versions' can't be converted to a boolean
at Microsoft.Azure.Management.ManagedServiceIdentity.UserAssignedIdentitiesOperations.GetWithHttpMessagesAsync(String resourceGroupName, String resourceName, Dictionary2 customHeaders, CancellationToken cancellationToken)
at Microsoft.Azure.Commands.ManagedServiceIdentity.UserAssignedIdentities.GetAzureRmUserAssignedIdentityCmdlet.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__31.b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 5:51:45 AM - GetAzureRmUserAssignedIdentityCmdlet end processing.
Not sure what caused the issue, but it is not a bug, the 0.7.3 works on my side.
It also works in cloud shell:
To fix the issue, try to update the Az module, then install the Az.ManagedServiceIdentity module.
Update-Module -Name Az -Force
Install-Module -Name Az.ManagedServiceIdentity -RequiredVersion 0.7.3
I am trying to use the API from https://api.emea.fortify.com/swagger/ui/index#/
called Start Scan with Default.
I cannot find any documentation to suggest how to set the post up.
This is what I have so far, but I get an error and of course I am not sending the files to scan either, so I know it is not right.
I have tried a Get request, which works so I know it is authenticated etc.
I just need to know are the parameters correctly formatted and how do I upload the actual files to scan.
POST /api/v3/releases/43579/static-scans/start-scan-with-defaults?releaseId=43579& fragNo=22& offset=22& isRemediationScan=false& notes=hello HTTP/1.1
Host: api.emea.fortify.com
Content-Type: application/json
Authorization: Bearer [TOKEN HERE]
User-Agent: PostmanRuntime/7.13.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 57e40c1d-c99c-40a4-a79b-06ef9a678a07,8ef4ad1e-327f-4eee-b6bb-bddb21b18d50
Host: api.emea.fortify.com
accept-encoding: gzip, deflate
content-length:
Connection: keep-alive
cache-control: no-cache
Response:
{
"errors": [
{
"errorCode": null,
"message": "Unexpected error processing request"
}
]
}
UPDATE
I have found this repo on Git written in Java, which I have tried to recreate in PowerShell with no success.
https://github.com/fod-dev/fod-uploader-java
My PowerShell:
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$zipDetails = Get-Content C:\Users\patemanc\Desktop\types.zip -Encoding Byte
Write-Host $zipDetails.Length
$releaseId = "43576"
$url = "https://api.emea.fortify.com/api/v3/releases/$releaseId/static-scans/start-scan-with-defaults?"
$url += "releaseId=$releaseId"
$url += "&fragNo=-1"
$url += "&offset=0"
$url += "&isRemediationScan=false"
$url += "¬es=PowrShell Test"
$long_lived_access_token = "ENTER TOKEN HERE"
$headers = #{Authorization = "bearer:$long_lived_access_token"}
$response = Invoke-WebRequest -ContentType "application/octet-stream" -Uri $url -Method POST -Body $zipDetails -Headers $headers -UseBasicParsing
Write-Host "Here is the end"
Write-Host $response
Error Response:
79212
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:22 char:13
+ $response = Invoke-WebRequest -ContentType "application/json" -Uri $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Why postman? If you use some plugin to run it, from Jenkins for example, it works fine. I don't know how the plugins call it from the API.
I had the below Powershell working perfectly until last November the 1st.
$url = "https://outlook.office365.com/api/v1.0/me/messages"
$date = Get-Date -Format "yyyy-MM-d"
## Get all messages that have attachments where received date is greater than $date
$messageQuery = "" + $url + "?`$select=Id&`$filter=HasAttachments eq true and DateTimeReceived ge " + $date
$messages = Invoke-RestMethod $messageQuery -Credential $cred
I get the below error:
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At G:\Powell\AutoetForO.ps1:23 char:13
+ $messages = Invoke-RestMethod $messageQuery -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Per my investigation; I know its not credential issues; I think they changed their API.
Running the same script with Fiddler capturing traffic I found the body of the error response was:
92
{"error":{"code":"RequestBroker-ParseUri","message":"Syntax error at position 54 in 'HasAttachments eq true and DateTimeReceived ge 2017-01-5'."}}
0
The date looked like the problem. Changing your second line to the following fixed the problem:
$date = Get-Date -Format "yyyy-MM-dd"
I am trying to get OAuth2 token for authorization on my local JHipster server.
Everything is setup correctly and working, I can login via Web GUI.
But when I try to get token via cURL I get POST method not allowed
My cURL request is as following:
curl -X POST -vu client:secret http://localhost:8080/oauth/token -H "Accept: application/json" -d "username=admin&password=admin&grant_type=password&scope=read&client_id=CLIENTID&client_secret=CLIENTSECRET"
Thanks to this post, I have tested JHipster UAA, alongside JHipster version 5 .
This command could be a working sample:
curl -X POST -v http://[server-ip]:9999/oauth/token -i
-H "Accept: application/json"
-H "Authorization: Basic aW50ZXJuYWw6aW50ZXJuYWw="
-d "username=admin&password=admin&grant_type=client_credentials&scope=web-app"
Important notice:
Username and password must be replaced with yours.
The BASE64 encoded value of your 'clientId + ":" + clientSecret' must be set in header.
In my case BASE64('internal:internal')='aW50ZXJuYWw6aW50ZXJuYWw='
https://www.base64encode.org/ can be used to encode your text.
Since you have put client Id and secret on message Header, no need to provide it on message body.
And this could be a sample output:
{
"access_token" : "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJ3ZWItYXBwIl0sImV4cCI6MTUzNTM2ODEyNiwiaWF0IjoxNTM1MzY2MzI2LCJqdGkiOiJiYjYwMWVkYS01NjUyLTQ5OTgtYWJkNS04YzYxZjA3Y2U1ODUiLCJjbGllbnRfaWQiOiJpbnRlcm5hbCJ9.lNqpfE7N6XJVFe9t7zPbwokU_zl4AFIAmQJZ_Hb2ok0vBpWrDMf3v6KgEEi5bN2iyRd0TQBelSIJothrsYHoTk0ZaeeK9BM97OJr4Uc8kLzn2Vp-xpBk8-n2PlwAKIRojoOxMnBp0nA2qjPieaPV2Fj1HETmK2gZ38lQcZ_KJLD-ug9AT9_N1E9SwRjt1yfZtd64IJZOQGqcZ05VCAj54jxH9lyvX-_1NY2Iq2aA5-cGbOftmv0sUjF15EiTGps6YtFUrJqKs8PmDofMImyqjAwB3yNObpg7c6PbeCXWYLAir5IOFdueTys3cLLyrhE78GJ3OiKSAA128nZSeUbiAg",
"token_type" : "bearer",
"expires_in" : 1799,
"scope" : "web-app",
"iat" : 1535366326,
"jti" : "bb601eda-5652-4998-abd5-8c61f07ce585"
* Connection #0 to host [server-ip] left intact
}
Using the default generated jhipster app (3.5.0), this is how you would curl a token for the admin user:
> curl -X POST -u jhipsterapp:my-secret-token-to-change-in-production -i -H 'Accept:application/json' http://localhost:8080/oauth/token -d "username=admin&password=admin&grant_type=password&scope=read%20write"
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Application-Context: jhipster:swagger,dev:8080
Cache-Control: no-store
Pragma: no-cache
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Fri, 22 Jul 2016 13:09:38 GMT
{
"access_token" : "4a1ae413-5cd7-46e9-8a33-31698218d43e",
"token_type" : "bearer",
"refresh_token" : "537f231c-e6e0-4499-bbd8-9580eee02f79",
"expires_in" : 1799,
"scope" : "read write"
}
Note: here is my .yo-rc.json:
{
"generator-jhipster": {
"jhipsterVersion": "3.5.0",
"baseName": "jhipster",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "oauth2",
"hibernateCache": "ehcache",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": "no",
"buildTool": "maven",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en"
]
}
}
I am getting an error and I don't understand why? I have googled and looked as much as I can and still do not have a clear answer. Here is what I am fast with.
Checking domain DC=corp,DC=local
Ldap Error(0x1 -- Operations Error): ldap_get_next_page_s
+ CategoryInfo : NotSpecified: (Ldap Error(0x1 ...get_next_page_s:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : computer01.corp.local
Error occured when searching for existing SPN: 0x00000001
Checking domain DC=corp,DC=local
Ldap Error(0x1 -- Operations Error): ldap_get_next_page_s
+ CategoryInfo : NotSpecified: (Ldap Error(0x1 ...get_next_page_s:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : computer01.corp.local
Error occured when searching for existing SPN: 0x00000001
This is the command I am running
$comp = "computer01.corp.local"
Invoke-Command -ComputerName $comp -ScriptBlock {
Invoke-Expression "SETSPN -S MSSQLSvc/$comp:1433 CORP\user.name"
Invoke-Expression "SETSPN -S MSSQLSvc/$comp CORP\user.name"
}
The variable $comp does not exist in your remote session, ie it is $null inside your -ScriptBlock{..} statement. Try this:
$comp = "computer01.corp.local"
Invoke-Command -ComputerName $comp -ScriptBlock {
param($comp)
Invoke-Expression "SETSPN -S MSSQLSvc/$comp:1433 CORP\user.name"
Invoke-Expression "SETSPN -S MSSQLSvc/$comp CORP\user.name"
} -ArgumentList $comp
You can add Write-Host "Working on computer:$comp" below param($comp) to verify you passed variable $comp correctly.