AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX: Программирование
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 22.11.2018, 14:27   #2  
pedrozzz is offline
pedrozzz
Молодой, подающий надежды
Аватар для pedrozzz
MCBMSS
Лучший по профессии 2015
 
164 / 218 (8) ++++++
Регистрация: 18.02.2010
Адрес: Краснодар
Сам вопрос задал, сам решил. Если вдруг кому пригодится.
Сначала некоторые подготовительные работы

Цитата:
Step 1. Authentication. For authentication, it is required to create an azure based application. Once this application creation is done, then you will get your ‘Client ID’ (or it is known as Application ID as well in azure portal for the application) and then you can generate (& Save) Client secret key as well. Both ‘ClientID’ and ‘Client Secret Key’ is required

Step 2. Registering and authorizing this application ID (or client ID) in Dynamics environment. Ensure that this ‘Client ID’ exist in Dynamics environment: Modules > System administration > Setup > Azure active directory applications. If record does not exist on the form, create a new one with details about Client ID, name:, and user Id. Ensure User ID = Admin.
И сам скрипт

X++:
$axBaseURL = "https://YOUR_NAME.cloudax.dynamics.com"

function D365-LoadPackage {
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$true)]$tenantId,
        [Parameter(Mandatory=$true)]$client_id,
        [Parameter(Mandatory=$true)]$client_Secret_key
    )

    $body = "resource=" + $axBaseURL + "&client_id=" + $client_id +"&client_secret=" + $client_Secret_key + "&grant_type=client_credentials"
    $url = "https://login.windows.net/" + $tenantId + "/oauth2/token"
    $apiToken = Invoke-RestMethod Uri $url -Method POST -Body $body -ContentType 'application/x-www-form-urlencoded'
    
    $url = "$axBaseURL/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.ImportFromPackage"

    $header = @{
    'Authorization' = 'Bearer ' + $apiToken.access_token
    }
        
    $body = @"
    {
        "packageUrl":"https://YOUR_ADDRESS.blob.core.windows.net/BLOB_NAME/FileName.zip",
        "definitionGroupId":"pk test",
        "executionId":"",
        "execute":"true",
        "overwrite":"true",
        "legalEntityId":"DAT"
    }
"@
    
    Invoke-RestMethod –Uri $url –Method POST –Headers $header -Body $body -ContentType "application/json" -ErrorAction Stop
    
}
__________________
Кононов Пётр
За это сообщение автора поблагодарили: Vadik (1), sukhanchik (2), Alex_KD (3).
Теги
data management, dyn365fo, odata, powershell, интеграция

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
goshoom: Find D365FO labels in Powershell Blog bot DAX Blogs 0 28.10.2018 17:11
D365FO - Как обновить изображение баннера в юридическом лице используя SQL и PowerShell MarinaAX DAX: Администрирование 8 22.10.2018 22:06
yetanotherdynamicsaxblog: List hotfixes using PowerShell in D365FO (AX7) Blog bot DAX Blogs 0 13.01.2018 20:21
jaestevan: PowerShell para la administración automática de Dynamics AX 2012 (PS-II) Blog bot DAX Blogs 0 28.06.2016 17:11

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 18:15.